home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / editor / editor2 / makeguide.lha / exec.doc next >
Text File  |  1996-10-10  |  162KB  |  5,263 lines

  1. exec.library/AbortIO
  2. exec.library/AddDevice
  3. exec.library/AddHead
  4. exec.library/AddIntServer
  5. exec.library/AddLibrary
  6. exec.library/AddMemHandler
  7. exec.library/AddMemList
  8. exec.library/AddPort
  9. exec.library/AddResource
  10. exec.library/AddSemaphore
  11. exec.library/AddTail
  12. exec.library/AddTask
  13. exec.library/Alert
  14. exec.library/AllocAbs
  15. exec.library/Allocate
  16. exec.library/AllocEntry
  17. exec.library/AllocMem
  18. exec.library/AllocPooled
  19. exec.library/AllocSignal
  20. exec.library/AllocTrap
  21. exec.library/AllocVec
  22. exec.library/AttemptSemaphore
  23. exec.library/AttemptSemaphoreShared
  24. exec.library/AvailMem
  25. exec.library/CacheClearE
  26. exec.library/CacheClearU
  27. exec.library/CacheControl
  28. exec.library/CachePostDMA
  29. exec.library/CachePreDMA
  30. exec.library/Cause
  31. exec.library/CheckIO
  32. exec.library/CloseDevice
  33. exec.library/CloseLibrary
  34. exec.library/ColdReboot
  35. exec.library/CopyMem
  36. exec.library/CopyMemQuick
  37. exec.library/CreateIORequest
  38. exec.library/CreateMsgPort
  39. exec.library/CreatePool
  40. exec.library/Deallocate
  41. exec.library/Debug
  42. exec.library/DeleteIORequest
  43. exec.library/DeleteMsgPort
  44. exec.library/DeletePool
  45. exec.library/Disable
  46. exec.library/DoIO
  47. exec.library/Enable
  48. exec.library/Enqueue
  49. exec.library/FindName
  50. exec.library/FindPort
  51. exec.library/FindResident
  52. exec.library/FindSemaphore
  53. exec.library/FindTask
  54. exec.library/Forbid
  55. exec.library/FreeEntry
  56. exec.library/FreeMem
  57. exec.library/FreePooled
  58. exec.library/FreeSignal
  59. exec.library/FreeTrap
  60. exec.library/FreeVec
  61. exec.library/GetCC
  62. exec.library/GetMsg
  63. exec.library/InitCode
  64. exec.library/InitResident
  65. exec.library/InitSemaphore
  66. exec.library/InitStruct
  67. exec.library/Insert
  68. exec.library/MakeFunctions
  69. exec.library/MakeLibrary
  70. exec.library/ObtainQuickVector
  71. exec.library/ObtainSemaphore
  72. exec.library/ObtainSemaphoreList
  73. exec.library/ObtainSemaphoreShared
  74. exec.library/OldOpenLibrary
  75. exec.library/OpenDevice
  76. exec.library/OpenLibrary
  77. exec.library/OpenResource
  78. exec.library/Permit
  79. exec.library/Procure
  80. exec.library/PutMsg
  81. exec.library/RawDoFmt
  82. exec.library/ReleaseSemaphore
  83. exec.library/ReleaseSemaphoreList
  84. exec.library/RemDevice
  85. exec.library/RemHead
  86. exec.library/RemIntServer
  87. exec.library/RemLibrary
  88. exec.library/RemMemHandler
  89. exec.library/Remove
  90. exec.library/RemPort
  91. exec.library/RemResource
  92. exec.library/RemSemaphore
  93. exec.library/RemTail
  94. exec.library/RemTask
  95. exec.library/ReplyMsg
  96. exec.library/SendIO
  97. exec.library/SetExcept
  98. exec.library/SetFunction
  99. exec.library/SetIntVector
  100. exec.library/SetSignal
  101. exec.library/SetSR
  102. exec.library/SetTaskPri
  103. exec.library/Signal
  104. exec.library/StackSwap
  105. exec.library/SumKickData
  106. exec.library/SumLibrary
  107. exec.library/SuperState
  108. exec.library/Supervisor
  109. exec.library/TypeOfMem
  110. exec.library/UserState
  111. exec.library/Vacate
  112. exec.library/Wait
  113. exec.library/WaitIO
  114. exec.library/WaitPort
  115. SAD/--Overview--
  116. SAD/ALLOCATE_MEMORY
  117. SAD/CALL_ADDRESS
  118. SAD/FREE_MEMORY
  119. SAD/GET_CONTEXT_FRAME
  120. SAD/NOP
  121. SAD/READ_ARRAY
  122. SAD/READ_BYTE
  123. SAD/READ_LONG
  124. SAD/READ_WORD
  125. SAD/RESET
  126. SAD/RETURN_TO_SYSTEM
  127. SAD/TURN_OFF_SINGLE
  128. SAD/TURN_ON_SINGLE
  129. SAD/WRITE_ARRAY
  130. SAD/WRITE_BYTE
  131. SAD/WRITE_LONG
  132. SAD/WRITE_WORD
  133. exec.library/AbortIO                                     exec.library/AbortIO
  134.  
  135.    NAME
  136.     AbortIO - attempt to abort an in-progress I/O request
  137.  
  138.    SYNOPSIS
  139.     AbortIO(iORequest)
  140.             A1
  141.  
  142.     VOID AbortIO(struct IORequest *);
  143.  
  144.    FUNCTION
  145.     Ask a device to abort a previously started IORequest.  This is done
  146.     by calling the device's ABORTIO vector, with your given IORequest.
  147.  
  148.  
  149.     AbortIO is a command the device that may or may not grant.  If
  150.     successful, the device will stop processing the IORequest, and
  151.     reply to it earlier than it would otherwise have done.
  152.  
  153.    NOTE
  154.     AbortIO() does NOT Remove() the IORequest from your ReplyPort, OR
  155.     wait for it to complete.  After an AbortIO() you must wait normally
  156.     for the reply message before actually reusing the request.
  157.  
  158.     If a request has already completed when AbortIO() is called, no
  159.     action is taken.
  160.  
  161.    EXAMPLE
  162.         AbortIO(timer_request);
  163.         WaitIO(timer_request);
  164.         /* Message is free to be reused */
  165.  
  166.    INPUTS
  167.     iORequest - pointer to an I/O request block (must have been used
  168.         at least once.  May be active or finished).
  169.  
  170.    SEE ALSO
  171.     WaitIO, DoIO, SendIO, CheckIO
  172.  
  173. exec.library/AddDevice                                 exec.library/AddDevice
  174.  
  175.    NAME
  176.     AddDevice -- add a device to the system
  177.  
  178.    SYNOPSIS
  179.     AddDevice(device)
  180.           A1
  181.  
  182.     void AddDevice(struct Device *);
  183.  
  184.    FUNCTION
  185.     This function adds a new device to the system device list, making
  186.     it available to other programs.  The device must be ready to be
  187.     opened at this time.
  188.  
  189.    INPUTS
  190.     device - pointer to a properly initialized device node
  191.  
  192.    SEE ALSO
  193.     RemDevice, OpenDevice, CloseDevice, MakeLibrary
  194.  
  195. exec.library/AddHead                                     exec.library/AddHead
  196.  
  197.    NAME
  198.     AddHead -- insert node at the head of a list
  199.  
  200.    SYNOPSIS
  201.     AddHead(list, node)
  202.         A0    A1
  203.  
  204.     void AddHead(struct List *, struct Node *)
  205.  
  206.    FUNCTION
  207.     Add a node to the head of a doubly linked list. Assembly
  208.     programmers may prefer to use the ADDHEAD macro from
  209.     "exec/lists.i".
  210.  
  211.    WARNING
  212.     This function does not arbitrate for access to the list.  The
  213.     calling task must be the owner of the involved list.
  214.  
  215.    INPUTS
  216.     list - a pointer to the target list header
  217.     node - the node to insert at head
  218.  
  219.    SEE ALSO
  220.     AddTail, Enqueue, Insert, Remove, RemHead, RemTail
  221.  
  222. exec.library/AddIntServer                           exec.library/AddIntServer
  223.  
  224.    NAME
  225.     AddIntServer -- add an interrupt server to a system server chain
  226.  
  227.    SYNOPSIS
  228.     AddIntServer(intNum, interrupt)
  229.              D0-0:4  A1
  230.  
  231.     void AddIntServer(ULONG, struct Interrupt *);
  232.  
  233.    FUNCTION
  234.     This function adds a new interrupt server to a given server chain.
  235.     The node is located on the chain in a priority dependent position.
  236.     If this is the first server on a particular chain, interrupts will
  237.     be enabled for that chain.
  238.  
  239.     Each link in the chain will be called in priority order until the
  240.     chain ends or one of the servers returns with the 68000's Z condition
  241.     code clear (indicating non-zero).  Servers on the chain should return
  242.     with the Z flag clear if the interrupt was specifically for that
  243.     server, and no one else.  VERTB servers should always return Z set.
  244.     (Take care with High Level Language servers, the language may not
  245.     have a mechanism for reliably setting the Z flag on exit).
  246.  
  247.     Servers are called with the following register conventions:
  248.  
  249.         D0 - scratch
  250.         D1 - scratch
  251.  
  252.         A0 - scratch
  253.         A1 - server is_Data pointer (scratch)
  254.  
  255.         A5 - jump vector register (scratch)
  256.         A6 - scratch
  257.  
  258.         all other registers must be preserved
  259.  
  260.    INPUTS
  261.     intNum - the Paula interrupt bit number (0 through 14). Processor
  262.          level seven interrupts (NMI) are encoded as intNum 15.
  263.          The PORTS, COPER, VERTB, EXTER and NMI interrupts are
  264.          set up as server chains.
  265.     interrupt - pointer to an Interrupt structure.
  266.          By convention, the LN_NAME of the interrupt structure must
  267.          point a descriptive string so that other users may
  268.          identify who currently has control of the interrupt.
  269.  
  270.    WARNING
  271.     Some compilers or assemblers may optimize code in unexpected ways,
  272.     affecting the conditions codes returned from the function.  Watch
  273.     out for a "MOVEM" instruction (which does not affect the condition
  274.     codes) turning into "MOVE" (which does).
  275.  
  276.    BUGS
  277.     The graphics library's VBLANK server, and some user code, currently
  278.     assume that address register A0 will contain a pointer to the custom
  279.     chips. If you add a server at a priority of 10 or greater, you must
  280.     compensate for this by providing the expected value ($DFF000).
  281.  
  282.    SEE ALSO
  283.     RemIntServer, SetIntVector, hardware/intbits.i,exec/interrupts.i
  284.  
  285. exec.library/AddLibrary                               exec.library/AddLibrary
  286.  
  287.    NAME
  288.     AddLibrary -- add a library to the system
  289.  
  290.    SYNOPSIS
  291.     AddLibrary(library)
  292.            A1
  293.  
  294.     void AddLibrary(struct Library *);
  295.  
  296.    FUNCTION
  297.     This function adds a new library to the system, making it available
  298.     to other programs.  The library should be ready to be opened at
  299.     this time.  It will be added to the system library name list, and
  300.     the checksum on the library entries will be calculated.
  301.  
  302.    INPUTS
  303.     library - pointer to a properly initialized library structure
  304.  
  305.    SEE ALSO
  306.     RemLibrary, CloseLibrary, OpenLibrary, MakeLibrary
  307.  
  308. exec.library/AddMemHandler                         exec.library/AddMemHandler
  309.  
  310.    NAME
  311.     AddMemHandler - Add a low memory handler to exec                 (V39)
  312.  
  313.    SYNOPSIS
  314.     AddMemHandler(memHandler)
  315.                   A1
  316.  
  317.     VOID AddMemHandler(struct Interrupt *);
  318.  
  319.    FUNCTION
  320.     This function adds a low memory handler to the system.  The handler
  321.     is described in the Interrupt structure.  Due to multitasking
  322.     issues, the handler must be ready to run the moment this function
  323.     call is made.  (The handler may be called before the call returns)
  324.  
  325.    NOTE
  326.     Adding a handler from within a handler will cause undefined
  327.     actions.  It is safe to add a handler to the list while within
  328.     a handler but the newly added handler may or may not be called
  329.     for the specific failure currently running.
  330.  
  331.    EXAMPLE
  332.     struct Interrupt *myInt;  /* Assume it is allocated */
  333.  
  334.     myInt->is_Node.ln_Pri=50;  /* Relatively early; before RAMLIB */
  335.  
  336.     /* Please fill in the name field! */
  337.     myInt->is_Node.ln_Name="Example Handler";
  338.  
  339.     myInt->is_Data=(APTR)mydata_pointer;
  340.     myInt->is_Code=myhandler_code;
  341.  
  342.     AddMemHandler(myInt);
  343.     ... /* and so on */
  344.  
  345.     _myhandler_code:
  346.             ; This is the handler code
  347.             ; We are passed a pointer to struct MemHandlerData
  348.             ; in a0, the value of is_Data in a1 and
  349.             ; ExecBase in a6.
  350.             ; We must not break forbid!!!
  351.     ;
  352.     ; Start off assuming we did nothing
  353.     ;
  354.         moveq.l    #MEM_DID_NOTHING,d0
  355.         move.l    memh_RequestFlags(a0),d1
  356.         btst.l    #MEMB_CHIP,d1    ; Did the failure happen in CHIP
  357.         beq.s    handler_nop    ; If not, we have nothing to do
  358.         bsr    DoMyMagic    ; Do the magic...
  359.         ; DoMyMagic frees whatever we can and returns d0 set...
  360.     handler_nop:
  361.         rts            ; Return with d0 set...
  362.  
  363.    INPUTS
  364.     memHandler - A pointer to a completely filled in Interrupt structure
  365.                  The priority field determine the position of the handler
  366.                  with respect to other handlers in the system.  The higher
  367.                  the priority, the earlier the handler is called.
  368.                  Positive priorities will have the handler called before
  369.                  any of the library expunge vectors are called.  Negative
  370.                  priority handlers will be called after the library
  371.                  expunge routines are called.
  372.                  (Note:  RAMLIB is a handler at priority 0)
  373.  
  374.    SEE ALSO
  375.     RemMemHandler, exec/interrupts.i
  376.  
  377. exec.library/AddMemList                               exec.library/AddMemList
  378.  
  379.    NAME
  380.     AddMemList - add memory to the system free pool
  381.  
  382.    SYNOPSIS
  383.     AddMemList( size, attributes, pri, base, name )
  384.                      D0      D1        D2   A0    A1
  385.  
  386.     void AddMemList(ULONG, ULONG, LONG, APTR, STRPTR);
  387.  
  388.    FUNCTION
  389.     Add a new region of memory to the system free pool.  The first few
  390.     bytes will be used to hold the MemHeader structure.  The remainder
  391.     will be made available to the rest of the world.
  392.  
  393.    INPUTS
  394.     size - the size (in bytes) of the memory area
  395.     attributes - the attributes word that the memory pool will have
  396.     pri  - the priority for this memory.  CHIP memory has a pri of -10,
  397.            16 bit expansion memory has a priority of 0.  The higher the
  398.            priority, the closer to the head of the memory list it will
  399.            be placed.
  400.     base - the base of the new memory area
  401.     name - the name that will be used in the memory header, or NULL
  402.            if no name is to be provided.  This name is not copied, so it
  403.            must remain valid for as long as the memory header is in the
  404.            system.
  405.  
  406.    NOTES
  407.     *DO NOT* add memory to the system with the attribute of MEMF_KICK.
  408.     EXEC will mark your memory as such if it is of the right type.
  409.  
  410.    SEE ALSO
  411.     AllocMem, exec/memory.h
  412.  
  413. exec.library/AddPort                                     exec.library/AddPort
  414.  
  415.    NAME
  416.     AddPort -- add a public message port to the system
  417.  
  418.    SYNOPSIS
  419.     AddPort(port)
  420.         A1
  421.  
  422.     void AddPort(struct MsgPort *);
  423.  
  424.    FUNCTION
  425.     This function attaches a message port structure to the system's
  426.     public message port list, where it can be found by the FindPort()
  427.     function.  The name and priority fields of the port structure must
  428.     be initialized prior to calling this function.    If the user does
  429.     not require the priority field, it should be initialized to zero.
  430.  
  431.     Only ports that will be searched for with FindPort() need to
  432.     be added to the system list.  In addition, adding ports is often
  433.     useful during debugging.  If the port will be searched for,
  434.     the priority field should be at least 1 (to avoid the large number
  435.     of inactive ports at priority zero).  If the port will be searched
  436.     for often, set the priority in the 50-100 range (so it will be
  437.     before other less used ports).
  438.  
  439.     Once a port has been added to the naming list, you must be careful
  440.     to remove the port from the list (via RemPort) before deallocating
  441.     its memory.
  442.  
  443.    NOTE
  444.     A point of confusion is that clearing a MsgPort structure to all
  445.     zeros is not enough to prepare it for use.  As mentioned in the
  446.     Exec chapter of the ROM Kernel Manual, the List for the MsgPort
  447.     must be initialized.  This is automatically handled by AddPort(),
  448.     and amiga.lib/CreatePort.  This initialization can be done manually
  449.     with amiga.lib/NewList or the assembly NEWLIST macro.
  450.  
  451.     Do not AddPort an active port.
  452.  
  453.    INPUTS
  454.     port - pointer to a message port
  455.  
  456.    SEE ALSO
  457.     RemPort, FindPort, amiga.lib/CreatePort, amiga.lib/NewList
  458.  
  459. exec.library/AddResource                             exec.library/AddResource
  460.  
  461.    NAME
  462.     AddResource -- add a resource to the system
  463.  
  464.    SYNOPSIS
  465.     AddResource(resource)
  466.             A1
  467.  
  468.     void AddResource(APTR);
  469.  
  470.    FUNCTION
  471.     This function adds a new resource to the system and makes it
  472.     available to other users.  The resource must be ready to be called
  473.     at this time.
  474.  
  475.     Resources currently have no system-imposed structure, however they
  476.     must start with a standard named node (LN_SIZE), and should with
  477.     a standard Library node (LIB_SIZE).
  478.  
  479.    INPUTS
  480.     resource - pointer an initialized resource node
  481.  
  482.    SEE ALSO
  483.     RemResource, OpenResource, MakeLibrary
  484.  
  485. exec.library/AddSemaphore                           exec.library/AddSemaphore
  486.  
  487.    NAME
  488.     AddSemaphore -- initialize then add a signal semaphore to the system
  489.  
  490.    SYNOPSIS
  491.     AddSemaphore(signalSemaphore)
  492.              A1
  493.  
  494.     void AddSemaphore(struct SignalSemaphore *);
  495.  
  496.    FUNCTION
  497.     This function attaches a signal semaphore structure to the system's
  498.     public signal semaphore list.  The name and priority fields of the
  499.     semaphore structure must be initialized prior to calling this
  500.     function.  If you do not want to let others rendezvous with this
  501.     semaphore, use InitSemaphore() instead.
  502.  
  503.     If a semaphore has been added to the naming list, you must be
  504.     careful to remove the semaphore from the list (via RemSemaphore)
  505.     before deallocating its memory.
  506.  
  507.     Semaphores that are linked together in an allocation list (which
  508.     ObtainSemaphoreList() would use) may not be added to the system
  509.     naming list, because the facilities use the link field of the
  510.     signal semaphore in incompatible ways
  511.  
  512.    INPUTS
  513.        signalSemaphore -- an signal semaphore structure
  514.  
  515.    BUGS
  516.     Does not work in Exec <V36.  Instead use this code:
  517.  
  518.         #include <exec/execbase.h>
  519.         #include <exec/nodes.h>
  520.         extern struct ExecBase *SysBase;
  521.         ...
  522.         void LocalAddSemaphore(s)
  523.         struct SignalSemaphore *s;
  524.         {
  525.         s->ss_Link.ln_Type=NT_SIGNALSEM;
  526.         InitSemaphore(s);
  527.         Forbid();
  528.         Enqueue(&SysBase->SemaphoreList,s);
  529.         Permit();
  530.         }
  531.  
  532.    SEE ALSO
  533.     RemSemaphore, FindSemaphore, InitSemaphore
  534.  
  535. exec.library/AddTail                                     exec.library/AddTail
  536.  
  537.    NAME
  538.     AddTail -- append node to tail of a list
  539.  
  540.    SYNOPSIS
  541.     AddTail(list, node)
  542.                 A0    A1
  543.  
  544.     void AddTail(struct List *, struct Node *);
  545.  
  546.    FUNCTION
  547.     Add a node to the tail of a doubly linked list.  Assembly
  548.     programmers may prefer to use the ADDTAIL macro from
  549.     "exec/lists.i".
  550.  
  551.    WARNING
  552.     This function does not arbitrate for access to the list.  The
  553.     calling task must be the owner of the involved list.
  554.  
  555.    INPUTS
  556.     list - a pointer to the target list header
  557.     node - a pointer to the node to insert at tail of the list
  558.  
  559.    SEE ALSO
  560.     AddHead, Enqueue, Insert, Remove, RemHead, RemTail
  561.  
  562. exec.library/AddTask                                     exec.library/AddTask
  563.  
  564.    NAME
  565.     AddTask -- add a task to the system
  566.  
  567.    SYNOPSIS
  568.     AddTask(task, initialPC, finalPC)
  569.         A1    A2     A3
  570.  
  571.     APTR AddTask(struct Task *, APTR, APTR);
  572.  
  573.    FUNCTION
  574.     Add a task to the system.  A reschedule will be run; the task with
  575.     the highest priority in the system will start to execute (this may
  576.     or may not be the new task).
  577.  
  578.     Certain fields of the task control block must be initialized and a
  579.     stack allocated prior to calling this function.  The absolute
  580.     smallest stack that is allowable is something in the range of 100
  581.     bytes, but in general the stack size is dependent on what
  582.     subsystems are called. In general 256 bytes is sufficient if only
  583.     Exec is called, and 4K will do if anything in the system is called.
  584.     DO NOT UNDERESTIMATE.  If you use a stack sniffing utility,
  585.     leave a healthy pad above the minimum value.  The system guarantees
  586.     that its stack operations will leave the stack longword aligned.
  587.  
  588.     This function will temporarily use space from the new task's stack
  589.     for the task's initial set of registers.  This space is allocated
  590.     starting at the SPREG location specified in the task control block
  591.     (not from SPUPPER).  This means that a task's stack may contain
  592.     static data put there prior to its execution.  This is useful for
  593.     providing initialized global variables or some tasks may want to
  594.     use this space for passing the task its initial arguments.
  595.  
  596.     A task's initial registers are set to zero (except the PC).
  597.  
  598.     The TC_MEMENTRY field of the task structure may be extended by
  599.     the user to hold additional MemLists (as returned by AllocEntry()).
  600.     These will be automatically be deallocated at RemTask() time.
  601.     If the code you have used to start the task has already added
  602.     something to the MEMENTRY list, simply use AddHead to add your
  603.     new MemLists in.  If no initialization has been done, a NewList will
  604.     need to be performed.
  605.  
  606.    INPUTS
  607.     task  - pointer to the task control block (TCB).  All unset fields
  608.         must be zero.
  609.     initialPC - the initial entry point's address
  610.     finalPC - the finalization code entry point's address.  If zero,
  611.           the system will use a general finalizer. This pointer is
  612.           placed on the stack as if it were the outermost return
  613.           address.
  614.  
  615.    RESULTS
  616.     For V36, AddTask returns either a NULL or the address of the new
  617.     task.  Old code need not check this.
  618.  
  619.    WARNING
  620.     Tasks are a low-level building block, and are unable to call
  621.     dos.library, or any system function that might call dos.library.
  622.     See the AmigaDOS CreateProc() for information on Processes.
  623.  
  624.    SEE ALSO
  625.     RemTask, FindTask, amiga.lib/CreateTask, dos/CreateProc,
  626.     amiga.lib/NewList
  627.  
  628. exec.library/Alert                                         exec.library/Alert
  629.  
  630.    NAME
  631.     Alert -- alert the user of an error
  632.  
  633.    SYNOPSIS
  634.     Alert(alertNum)
  635.           D7
  636.  
  637.     void Alert(ULONG);
  638.  
  639.    FUNCTION
  640.     Alerts the user of a serious system problem.  This function will
  641.     bring the system to a grinding halt, and do whatever is necessary
  642.     to present the user with a message stating what happened.
  643.     Interrupts are disabled, and an attempt to post the alert is made.
  644.     If that fails, the system is reset.  When the system comes up
  645.     again, Exec notices the cause of the failure and tries again to
  646.     post the alert.
  647.  
  648.     If the Alert is a recoverable type, this call MAY return.
  649.  
  650.     This call may be made at any time, including interrupts.
  651.     (Well, only in interrupts if it is non-recoverable)
  652.  
  653.     New, for V39:
  654.     The alert now times out based on the value in LastAlert[3]
  655.     This value is transfered accross warm-reboots and thus will let
  656.     you set it once.  The value is the number of frames that need to
  657.     be displayed before the alert is auto-answered.  A value of
  658.     0 will thus make the alert never be displayed.  Note that
  659.     it is recommended that applications *NOT* change the value in
  660.     LastAlert[] since the main reason for this is to make
  661.     unattended operation of the Amiga (in production enviroments)
  662.     possible.
  663.  
  664.    POST-MORTEM DIAGNOSIS
  665.     There are several options for determining the cause of a crash.
  666.     Descriptions of each alert number can be found in the "alerts.h"
  667.     include file.
  668.  
  669.     A remote terminal can be attached to the Amiga's first built-in
  670.     serial port.  Set the communication parameters to 9600 baud, 8 bits,
  671.     no parity.  Before resetting the machine, the Alert function will
  672.     blink the power LED 10 times.  While the power indicator is flashing,
  673.     pressing DELETE on the remote terminal will invoke the ROM debugger.
  674.  
  675.    INPUT
  676.     alertNum   - a number indicating the particular alert.  -1 is
  677.                  not a valid input.
  678.  
  679.    NOTE
  680.     Much more needs to be said about this function and its implications.
  681.  
  682.    SEE ALSO
  683.     exec/alerts.h
  684.  
  685. exec.library/AllocAbs                                   exec.library/AllocAbs
  686.  
  687.    NAME
  688.     AllocAbs -- allocate at a given location
  689.  
  690.    SYNOPSIS
  691.     memoryBlock = AllocAbs(byteSize, location)
  692.     D0               D0     A1
  693.  
  694.     void *AllocAbs(ULONG, APTR);
  695.  
  696.    FUNCTION
  697.     This function attempts to allocate memory at a given absolute
  698.     memory location.  Often this is used by boot-surviving entities
  699.     such as recoverable ram-disks.    If the memory is already being
  700.     used, or if there is not enough memory to satisfy the request,
  701.     AllocAbs will return NULL.
  702.  
  703.     This block may not be exactly the same as the requested block
  704.     because of rounding, but if the return value is non-zero, the block
  705.     is guaranteed to contain the requested range.
  706.  
  707.    INPUTS
  708.     byteSize - the size of the desired block in bytes
  709.            This number is rounded up to the next larger
  710.            block size for the actual allocation.
  711.     location - the address where the memory MUST be.
  712.  
  713.  
  714.    RESULT
  715.     memoryBlock - a pointer to the newly allocated memory block, or
  716.               NULL if failed.
  717.  
  718.    NOTE
  719.     If the free list is corrupt, the system will panic with alert
  720.     AN_MemCorrupt, $01000005.
  721.  
  722.     The 8 bytes past the end of an AllocAbs will be changed by Exec
  723.     relinking the next block of memory.  Generally you can't trust
  724.     the first 8 bytes of anything you AllocAbs.
  725.  
  726.    SEE ALSO
  727.     AllocMem, FreeMem
  728.  
  729. exec.library/Allocate                                   exec.library/Allocate
  730.  
  731.    NAME
  732.     Allocate - allocate a block of memory
  733.  
  734.    SYNOPSIS
  735.     memoryBlock=Allocate(memHeader, byteSize)
  736.     D0             A0     D0
  737.  
  738.     void *Allocate(struct MemHeader *, ULONG);
  739.  
  740.    FUNCTION
  741.     This function is used to allocate blocks of memory from a given
  742.     private free memory pool (as specified by a MemHeader and its
  743.     memory chunk list).  Allocate will return the first free block that
  744.     is greater than or equal to the requested size.
  745.  
  746.     All blocks, whether free or allocated, will be block aligned;
  747.     hence, all allocation sizes are rounded up to the next block even
  748.     value (e.g. the minimum allocation resolution is currently 8
  749.     bytes.  A request for 8 bytes will use up exactly 8 bytes.  A
  750.     request for 7 bytes will also use up exactly 8 bytes.).
  751.  
  752.     This function can be used to manage an application's internal data
  753.     memory.  Note that no arbitration of the MemHeader and associated
  754.     free chunk list is done.  You must be the owner before calling
  755.     Allocate.
  756.  
  757.    INPUTS
  758.     memHeader - points to the local memory list header.
  759.     byteSize - the size of the desired block in bytes.
  760.  
  761.    RESULT
  762.     memoryBlock - a pointer to the just allocated free block.
  763.            If there are no free regions large enough to satisfy the
  764.            request, return zero.
  765.  
  766.    EXAMPLE
  767.     #include <exec/types.h>
  768.     #include <exec/memory.h>
  769.     void *AllocMem();
  770.     #define BLOCKSIZE 4096L /* Or whatever you want */
  771.  
  772.     void main()
  773.     {
  774.     struct MemHeader *mh;
  775.     struct MemChunk  *mc;
  776.     APTR   block1;
  777.     APTR   block2;
  778.  
  779.         /* Get the MemHeader needed to keep track of our new block */
  780.         mh = (struct MemHeader *)
  781.          AllocMem((long)sizeof(struct MemHeader), MEMF_CLEAR );
  782.         if( !mh )
  783.         exit(10);
  784.  
  785.         /* Get the actual block the above MemHeader will manage */
  786.         mc = (struct MemChunk *)AllocMem( BLOCKSIZE, 0L );
  787.         if( !mc )
  788.         {
  789.         FreeMem( mh, (long)sizeof(struct MemHeader) ); exit(10);
  790.         }
  791.  
  792.         mh->mh_Node.ln_Type = NT_MEMORY;
  793.         mh->mh_Node.ln_Name = "myname";
  794.         mh->mh_First = mc;
  795.         mh->mh_Lower = (APTR) mc;
  796.         mh->mh_Upper = (APTR) ( BLOCKSIZE + (ULONG) mc );
  797.         mh->mh_Free  = BLOCKSIZE;
  798.  
  799.         /* Set up first chunk in the freelist */
  800.         mc->mc_Next  = NULL;
  801.         mc->mc_Bytes = BLOCKSIZE;
  802.  
  803.         block1 = (APTR) Allocate( mh, 20L );
  804.         block2 = (APTR) Allocate( mh, 314L );
  805.         printf("mh=$%lx mc=$%lx\n",mh,mc);
  806.         printf("Block1=$%lx, Block2=$%lx\n",block1,block2);
  807.  
  808.         FreeMem( mh, (long)sizeof(struct MemHeader) );
  809.         FreeMem( mc, BLOCKSIZE );
  810.     }
  811.  
  812.    NOTE
  813.     If the free list is corrupt, the system will panic with alert
  814.     AN_MemCorrupt, $01000005.
  815.  
  816.    SEE ALSO
  817.     Deallocate, exec/memory.h
  818.  
  819. exec.library/AllocEntry                               exec.library/AllocEntry
  820.  
  821.    NAME
  822.     AllocEntry -- allocate many regions of memory
  823.  
  824.    SYNOPSIS
  825.     memList = AllocEntry(memList)
  826.     D0             A0
  827.  
  828.     struct MemList *AllocEntry(struct MemList *);
  829.  
  830.    FUNCTION
  831.     This function takes a memList structure and allocates enough memory
  832.     to hold the required memory as well as a MemList structure to keep
  833.     track of it.
  834.  
  835.     These MemList structures may be linked together in a task control
  836.     block to keep track of the total memory usage of this task. (See
  837.     the description of TC_MEMENTRY under RemTask).
  838.  
  839.    INPUTS
  840.     memList -- A MemList structure filled in with MemEntry structures.
  841.  
  842.    RESULTS
  843.     memList -- A different MemList filled in with the actual memory
  844.         allocated in the me_Addr field, and their sizes in me_Length.
  845.         If enough memory cannot be obtained, then the requirements of
  846.         the allocation that failed is returned and bit 31 is set.
  847.  
  848.         WARNING: The result is unusual!  Bit 31 indicates failure.
  849.  
  850.    EXAMPLES
  851.     The user wants five regions of 2, 4, 8, 16, and 32 bytes in size
  852.     with requirements of MEMF_CLEAR, MEMF_PUBLIC, MEMF_CHIP!MEMF_CLEAR,
  853.     MEMF_CLEAR, and MEMF_PUBLIC!MEMF_CLEAR respectively.  The
  854.     following code fragment would do that:
  855.  
  856.         MemListDecl:
  857.         DS.B    LN_SIZE         * reserve space for list node
  858.         DC.W    5            * number of entries
  859.         DC.L    MEMF_CLEAR            * entry #0
  860.         DC.L    2
  861.         DC.L    MEMF_PUBLIC            * entry #1
  862.         DC.L    4
  863.         DC.L    MEMF_CHIP!MEMF_CLEAR        * entry #2
  864.         DC.L    8
  865.         DC.L    MEMF_CLEAR               * entry #3
  866.         DC.L    16
  867.         DC.L    MEMF_PUBLIC!MEMF_CLEAR        * entry #4
  868.         DC.L    32
  869.  
  870.         start:
  871.         LEA.L    MemListDecl(PC),A0
  872.         JSR    _LVOAllocEntry(a6)
  873.         BCLR.L    #31,D0
  874.         BEQ.S    success
  875.  
  876.         ------- Type of memory that we failed on is in D0
  877.  
  878.    BUGS
  879.     If any one of the allocations fails, this function fails to back
  880.     out fully.  This is fixed by the "SetPatch" program on V1.3
  881.     Workbench disks.
  882.  
  883.    SEE ALSO
  884.     exec/memory.h
  885.  
  886. exec.library/AllocMem                                   exec.library/AllocMem
  887.  
  888.    NAME
  889.     AllocMem -- allocate memory given certain requirements
  890.  
  891.    SYNOPSIS
  892.     memoryBlock = AllocMem(byteSize, attributes)
  893.     D0               D0     D1
  894.  
  895.     void *AllocMem(ULONG, ULONG);
  896.  
  897.    FUNCTION
  898.     This is the memory allocator to be used by system code and
  899.     applications.  It provides a means of specifying that the allocation
  900.     should be made in a memory area accessible to the chips, or
  901.     accessible to shared system code.
  902.  
  903.     Memory is allocated based on requirements and options.    Any
  904.     "requirement" must be met by a memory allocation, any "option" will
  905.     be applied to the block regardless.  AllocMem will try all memory
  906.     spaces until one is found with the proper requirements and room for
  907.     the memory request.
  908.  
  909.    INPUTS
  910.     byteSize - the size of the desired block in bytes.  (The operating
  911.         system will automatically round this number to a multiple of
  912.         the system memory chunk size)
  913.  
  914.     attributes -
  915.         requirements
  916.  
  917.         If no flags are set, the system will return the best
  918.         available memory block.  For expanded systems, the fast
  919.         memory pool is searched first.
  920.  
  921.         MEMF_CHIP:    If the requested memory will be used by
  922.                 the Amiga custom chips, this flag *must*
  923.                 be set.
  924.  
  925.                 Only certain parts of memory are reachable
  926.                 by the special chip sets' DMA circuitry.
  927.                 Chip DMA includes screen memory, images that
  928.                 are blitted, audio data, copper lists, sprites
  929.                 and Pre-V36 trackdisk.device buffers.
  930.  
  931.  
  932.         MEMF_FAST:    This is non-chip memory.  If no flag is set
  933.                 MEMF_FAST is taken as the default.
  934.  
  935.                 DO NOT SPECIFY MEMF_FAST unless you know
  936.                 exactly what you are doing!  If MEMF_FAST is
  937.                 set, AllocMem() will fail on machines that
  938.                 only have chip memory!  This flag may not
  939.                 be set when MEMF_CHIP is set.
  940.  
  941.  
  942.         MEMF_PUBLIC:    Memory that must not be mapped, swapped,
  943.                 or otherwise made non-addressable. ALL
  944.                 MEMORY THAT IS REFERENCED VIA INTERRUPTS
  945.                 AND/OR BY OTHER TASKS MUST BE EITHER PUBLIC
  946.                 OR LOCKED INTO MEMORY! This includes both
  947.                 code and data.
  948.  
  949.  
  950.         MEMF_LOCAL:    This is memory that will not go away
  951.                 after the CPU RESET instruction.  Normally,
  952.                 autoconfig memory boards become unavailable
  953.                 after RESET while motherboard memory
  954.                 may still be available.  This memory type
  955.                 is now automatically set in V36.  Pre-V36
  956.                 systems may not have this memory type
  957.                 and AllocMem() will then fail.
  958.  
  959.  
  960.         MEMF_24BITDMA:    This is memory that is within the address
  961.                 range of 24-bit DMA devices.  (Zorro-II)
  962.                 This is required if you run a Zorro-II
  963.                 DMA device on a machine that has memory
  964.                 beyond the 24-bit addressing limit of
  965.                 Zorro-II.  This memory type
  966.                 is now automatically set in V36.  Pre-V36
  967.                 systems may not have this memory type
  968.                 and AllocMem() will then fail.
  969.  
  970.  
  971.         MEMF_KICK:    This memory is memory that EXEC was able
  972.                 to access during/before the KickMem and
  973.                 KickTags are processed.  This means that
  974.                 if you wish to use these, you should allocate
  975.                 memory with this flag.  This flag is
  976.                 automaticly set by EXEC in V39.  Pre-V39
  977.                 systems may not have this memory type and
  978.                 AllocMem() will then fail.  Also, *DO NOT*
  979.                 ever add memory the system with this flag
  980.                 set.  EXEC will set the flag as needed
  981.                 if the memory matches the needs of EXEC.
  982.  
  983.  
  984.         options
  985.  
  986.         MEMF_CLEAR:    The memory will be initialized to all
  987.                 zeros.
  988.  
  989.  
  990.         MEMF_REVERSE:    This allocates memory from the top of
  991.                 the memory pool.  It searches the pools
  992.                 in the same order, such that FAST memory
  993.                 will be found first.  However, the
  994.                 memory will be allocated from the highest
  995.                 address available in the pool.  This
  996.                 option is new as of V36.  Note that this
  997.                 option has a bug in pre-V39 systems.
  998.  
  999.  
  1000.         MEMF_NO_EXPUNGE    This will prevent an expunge to happen on
  1001.                 a failed memory allocation.  This option is
  1002.                 new to V39 and will be ignored in V37.
  1003.                 If a memory allocation with this flag
  1004.                 set fails, the allocator will not cause
  1005.                 any expunge operations.  (See AddMemHandler())
  1006.  
  1007.  
  1008.    RESULT
  1009.     memoryBlock - a pointer to the newly allocated memory block.
  1010.         If there are no free memory regions large enough to satisfy
  1011.         the request, zero will be returned.  The pointer must be
  1012.         checked for zero before the memory block may be used!
  1013.         The memory block returned is long word aligned.
  1014.  
  1015.    WARNING
  1016.     The result of any memory allocation MUST be checked, and a viable
  1017.     error handling path taken.  ANY allocation may fail if memory has
  1018.     been filled.
  1019.  
  1020.    EXAMPLES
  1021.     AllocMem(64,0L)        - Allocate the best available memory
  1022.     AllocMem(25,MEMF_CLEAR) - Allocate the best available memory, and
  1023.                   clear it before returning.
  1024.     AllocMem(128,MEMF_CHIP) - Allocate chip memory
  1025.     AllocMem(128,MEMF_CHIP|MEMF_CLEAR) - Allocate cleared chip memory
  1026.     AllocMem(821,MEMF_CHIP|MEMF_PUBLIC|MEMF_CLEAR) - Allocate cleared,
  1027.         public, chip memory.
  1028.  
  1029.    NOTE
  1030.     If the free list is corrupt, the system will panic with alert
  1031.     AN_MemCorrupt, $01000005.
  1032.  
  1033.     This function may not be called from interrupts.
  1034.  
  1035.     A DOS process will have its pr_Result2 field set to
  1036.     ERROR_NO_FREE_STORE if the memory allocation fails.
  1037.  
  1038.    SEE ALSO
  1039.     FreeMem
  1040.  
  1041. exec.library/AllocPooled                             exec.library/AllocPooled
  1042.  
  1043.     NAME
  1044.     AllocPooled -- Allocate memory with the pool manager (V39)
  1045.  
  1046.     SYNOPSIS
  1047.     memory=AllocPooled(poolHeader,memSize)
  1048.     d0                 a0         d0
  1049.  
  1050.     void *AllocPooled(void *,ULONG);
  1051.  
  1052.     FUNCTION
  1053.     Allocate memSize bytes of memory, and return a pointer. NULL is
  1054.     returned if the allocation fails.
  1055.  
  1056.     Doing a DeletePool() on the pool will free all of the puddles
  1057.     and thus all of the allocations done with AllocPooled() in that
  1058.     pool.  (No need to FreePooled() each allocation)
  1059.  
  1060.     INPUTS
  1061.     memSize - the number of bytes to allocate
  1062.     poolHeader - a specific private pool header.
  1063.  
  1064.     RESULT
  1065.     A pointer to the memory, or NULL.
  1066.     The memory block returned is long word aligned.
  1067.  
  1068.     NOTES
  1069.     The pool function do not protect an individual pool from
  1070.     multiple accesses.  The reason is that in most cases the pools
  1071.     will be used by a single task.  If your pool is going to
  1072.     be used by more than one task you must Semaphore protect
  1073.     the pool from having more than one task trying to allocate
  1074.     within the same pool at the same time.  Warning:  Forbid()
  1075.     protection *will not work* in the future.  *Do NOT* assume
  1076.     that we will be able to make it work in the future.  AllocPooled()
  1077.     may well break a Forbid() and as such can only be protected
  1078.     by a semaphore.
  1079.  
  1080.     To track sizes yourself, the following code can be used:
  1081.     Assumes a6=ExecBase
  1082.  
  1083.     ;
  1084.     ; Function to do AllocVecPooled(Pool,memSize)
  1085.     ;
  1086.     AllocVecPooled:    addq.l    #4,d0        ; Get space for tracking
  1087.             move.l    d0,-(sp)    ; Save the size
  1088.             jsr    _LVOAllocPooled(a6)    ; Call pool...
  1089.             move.l    (sp)+,d1    ; Get size back...
  1090.             tst.l    d0        ; Check for error
  1091.             beq.s    avp_fail    ; If NULL, failed!
  1092.             move.l    d0,a0        ; Get pointer...
  1093.             move.l    d1,(a0)+    ; Store size
  1094.             move.l    a0,d0        ; Get result
  1095.     avp_fail:    rts            ; return
  1096.  
  1097.     ;
  1098.     ; Function to do FreeVecPooled(pool,memory)
  1099.     ;
  1100.     FreeVecPooled:    move.l    -(a1),d0    ; Get size / ajust pointer
  1101.             jmp    _LVOFreePooled(a6)
  1102.  
  1103.     SEE ALSO
  1104.     FreePooled(), CreatePool(), DeletePool()
  1105.  
  1106. exec.library/AllocSignal                             exec.library/AllocSignal
  1107.  
  1108.    NAME
  1109.     AllocSignal -- allocate a signal bit
  1110.  
  1111.    SYNOPSIS
  1112.     signalNum = AllocSignal(signalNum)
  1113.     D0            D0
  1114.  
  1115.     BYTE AllocSignal(BYTE);
  1116.  
  1117.    FUNCTION
  1118.     Allocate a signal bit from the current tasks' pool.  Either a
  1119.     particular bit, or the next free bit may be allocated.    The signal
  1120.     associated with the bit will be properly initialized (cleared).  At
  1121.     least 16 user signals are available per task.  Signals should be
  1122.     deallocated before the task exits.
  1123.  
  1124.     If the signal is already in use (or no free signals are available)
  1125.     a -1 is returned.
  1126.  
  1127.     Allocated signals are only valid for use with the task that
  1128.     allocated them.
  1129.  
  1130.  
  1131.    WARNING
  1132.     Signals may not be allocated or freed from exception handling code.
  1133.  
  1134.    INPUTS
  1135.     signalNum - the desired signal number {of 0..31} or -1 for no
  1136.             preference.
  1137.  
  1138.    RESULTS
  1139.     signalNum - the signal bit number allocated {0..31}. If no signals
  1140.             are available, this function returns -1.
  1141.  
  1142.    SEE ALSO
  1143.     FreeSignal
  1144.  
  1145. exec.library/AllocTrap                                 exec.library/AllocTrap
  1146.  
  1147.    NAME
  1148.     AllocTrap -- allocate a processor trap vector
  1149.  
  1150.    SYNOPSIS
  1151.     trapNum = AllocTrap(trapNum)
  1152.     D0            D0
  1153.  
  1154.     LONG AllocTrap(LONG);
  1155.  
  1156.    FUNCTION
  1157.     Allocate a trap number from the current task's pool.  These trap
  1158.     numbers are those associated with the 68000 TRAP type instructions.
  1159.     Either a particular number, or the next free number may be
  1160.     allocated.
  1161.  
  1162.     If the trap is already in use (or no free traps are available) a -1
  1163.     is returned.
  1164.  
  1165.     This function only affects the currently running task.
  1166.  
  1167.     Traps are sent to the trap handler pointed at by tc_TrapCode.
  1168.     Unless changed by user code, this points to a standard trap
  1169.     handler.  The stack frame of the exception handler will be:
  1170.  
  1171.         0(SP) = Exception vector number.  This will be in the
  1172.             range of 32 to 47 (corresponding to the
  1173.             Trap #1...Trap #15 instructions).
  1174.         4(SP) = 68000/68010/68020/68030, etc. exception frame
  1175.  
  1176.     tc_TrapData is not used.
  1177.  
  1178.  
  1179.    WARNING
  1180.     Traps may not be allocated or freed from exception handling code.
  1181.     You are not allowed to write to the exception table yourself.  In
  1182.     fact, on some machines you will have trouble finding it - the VBR
  1183.     register may be used to remap its location.
  1184.  
  1185.    INPUTS
  1186.     trapNum - the desired trap number {of 0..15} or -1
  1187.           for no preference.
  1188.  
  1189.    RESULTS
  1190.     trapNum - the trap number allocated {of 0..15}.  If no traps are
  1191.           available, this function returns -1.    Instructions of the
  1192.           form "Trap #trapNum" will be sent to the task's trap
  1193.           handler.
  1194.  
  1195.    SEE ALSO
  1196.     FreeTrap
  1197.  
  1198. exec.library/AllocVec                                   exec.library/AllocVec
  1199.  
  1200.    NAME
  1201.     AllocVec -- allocate memory and keep track of the size  (V36)
  1202.  
  1203.    SYNOPSIS
  1204.     memoryBlock = AllocVec(byteSize, attributes)
  1205.     D0               D0     D1
  1206.  
  1207.     void *AllocVec(ULONG, ULONG);
  1208.  
  1209.    FUNCTION
  1210.     This function works identically to AllocMem(), but tracks the size
  1211.     of the allocation.
  1212.  
  1213.     See the AllocMem() documentation for details.
  1214.  
  1215.    WARNING
  1216.     The result of any memory allocation MUST be checked, and a viable
  1217.     error handling path taken.  ANY allocation may fail if memory has
  1218.     been filled.
  1219.  
  1220.    SEE ALSO
  1221.     FreeVec, AllocMem
  1222.  
  1223. exec.library/AttemptSemaphore                   exec.library/AttemptSemaphore
  1224.  
  1225.    NAME
  1226.     AttemptSemaphore -- try to obtain without blocking
  1227.  
  1228.    SYNOPSIS
  1229.     success = AttemptSemaphore(signalSemaphore)
  1230.     D0               A0
  1231.  
  1232.     LONG AttemptSemaphore(struct SignalSemaphore *);
  1233.  
  1234.    FUNCTION
  1235.     This call is similar to ObtainSemaphore(), except that it will not
  1236.     block if the semaphore could not be locked.
  1237.  
  1238.    INPUT
  1239.        signalSemaphore -- an initialized signal semaphore structure
  1240.  
  1241.    RESULT
  1242.     success -- TRUE if the semaphore was locked, false if some
  1243.         other task already possessed the semaphore.
  1244.  
  1245.     NOTE
  1246.     This call does NOT preserve registers.
  1247.  
  1248.    SEE ALSO
  1249.     ObtainSemaphore() ObtainSemaphoreShared(), ReleaseSemaphore(),
  1250.     exec/semaphores.h
  1251.  
  1252. exec.library/AttemptSemaphoreShared       exec.library/AttemptSemaphoreShared
  1253.  
  1254.    NAME
  1255.     AttemptSemaphoreShared -- try to obtain without blocking       (V37)
  1256.  
  1257.    SYNOPSIS
  1258.     success = AttemptSemaphoreShared(signalSemaphore)
  1259.     D0                     A0
  1260.  
  1261.     LONG AttemptSemaphoreShared(struct SignalSemaphore *);
  1262.  
  1263.    FUNCTION
  1264.     This call is similar to ObtainSemaphoreShared(), except that it
  1265.     will not block if the semaphore could not be locked.
  1266.  
  1267.    INPUT
  1268.        signalSemaphore -- an initialized signal semaphore structure
  1269.  
  1270.    RESULT
  1271.     success -- TRUE if the semaphore was granted, false if some
  1272.         other task already possessed the semaphore in exclusive mode.
  1273.  
  1274.    NOTE
  1275.     This call does NOT preserve registers.
  1276.  
  1277.     Starting in V39 this call will grant the semaphore if the
  1278.     caller is already the owner of an exclusive lock on the semaphore.
  1279.     In pre-V39 systems this would not be the case.  If you need this
  1280.     feature you can do the following workaround:
  1281.  
  1282.     LONG myAttemptSempahoreShared(struct SignalSemaphore *ss)
  1283.     {
  1284.     LONG result;
  1285.  
  1286.         /* Try for a shared semaphore */
  1287.         if (!(result=AttemptSemaphoreShared(ss)))
  1288.         {
  1289.             /* Now try for the exclusive one... */
  1290.             result=AttempSemaphore(ss);
  1291.         }
  1292.         return(result);
  1293.     }
  1294.  
  1295.    SEE ALSO
  1296.     ObtainSemaphore() ObtainSemaphoreShared(), ReleaseSemaphore(),
  1297.     exec/semaphores.h
  1298.  
  1299. exec.library/AvailMem                                   exec.library/AvailMem
  1300.  
  1301.    NAME
  1302.     AvailMem -- memory available given certain requirements
  1303.  
  1304.    SYNOPSIS
  1305.     size = AvailMem(attributes)
  1306.     D0        D1
  1307.  
  1308.     ULONG AvailMem(ULONG);
  1309.  
  1310.    FUNCTION
  1311.     This function returns the amount of free memory given certain
  1312.     attributes.
  1313.  
  1314.     To find out what the largest block of a particular type is, add
  1315.     MEMF_LARGEST into the requirements argument.  Returning the largest
  1316.     block is a slow operation.
  1317.  
  1318.    WARNING
  1319.     Due to the effect of multitasking, the value returned may not
  1320.     actually be the amount of free memory available at that instant.
  1321.  
  1322.    INPUTS
  1323.     requirements - a requirements mask as specified in AllocMem.  Any
  1324.                of the AllocMem bits are valid, as is MEMF_LARGEST
  1325.                which returns the size of the largest block matching
  1326.                the requirements.
  1327.  
  1328.    RESULT
  1329.     size - total free space remaining (or the largest free block).
  1330.  
  1331.    NOTE
  1332.     For V36 Exec, AvailMem(MEMF_LARGEST) does a consistency check on
  1333.     the memory list.  Alert AN_MemoryInsane will be pulled if any mismatch
  1334.     is noted.
  1335.  
  1336.    EXAMPLE
  1337.     AvailMem(MEMF_CHIP|MEMF_LARGEST);
  1338.     /* return size of largest available chip memory chunk */
  1339.  
  1340.    SEE ALSO
  1341.     exec/memory.h
  1342.  
  1343. exec.library/CacheClearE                             exec.library/CacheClearE
  1344.  
  1345.    NAME
  1346.     CacheClearE - Cache clearing with extended control (V37)
  1347.  
  1348.    SYNOPSIS
  1349.     CacheClearE(address,length,caches)
  1350.                 a0      d0     d1
  1351.  
  1352.     void CacheClearE(APTR,ULONG,ULONG);
  1353.  
  1354.    FUNCTION
  1355.     Flush out the contents of the CPU instruction and/or data caches.
  1356.     If dirty data cache lines are present, push them to memory first.
  1357.  
  1358.     Motorola CPUs have separate instruction and data caches.  A data
  1359.     write does not update the instruction cache.  If an instruction is
  1360.     written to memory or modified, the old instruction may still exist
  1361.     in the cache.  Before attempting to execute the code, a flush of
  1362.     the instruction cache is required.
  1363.  
  1364.     For most systems, the data cache is not updated by Direct Memory
  1365.     Access (DMA), or if some external factor changes shared memory.
  1366.  
  1367.     Caches must be cleared after *any* operation that could cause
  1368.     invalid or stale data.  The most common cases are DMA and modifying
  1369.     instructions using the processor.
  1370.  
  1371.     Some examples:
  1372.             Self modifying code
  1373.             Building Jump tables
  1374.             Run-time code patches
  1375.             Relocating code for use at different addresses.
  1376.             Loading code from disk
  1377.  
  1378.    INPUTS
  1379.     address - Address to start the operation.  This may be rounded
  1380.           due to hardware granularity.
  1381.     length    - Length of area to be cleared, or $FFFFFFFF to indicate all
  1382.           addresses should be cleared.
  1383.     caches  - Bit flags to indicate what caches to affect.  The current
  1384.           supported flags are:
  1385.             CACRF_ClearI    ;Clear instruction cache
  1386.             CACRF_ClearD    ;Clear data cache
  1387.           All other bits are reserved for future definition.
  1388.  
  1389.    NOTES
  1390.     On systems with a copyback mode cache, any dirty data is pushed
  1391.     to memory as a part of this operation.
  1392.  
  1393.     Regardless of the length given, the function will determine the most
  1394.     efficient way to implement the operation.  For some cache systems,
  1395.     including the 68030, the overhead partially clearing a cache is often
  1396.     too great.  The entire cache may be cleared.
  1397.  
  1398.     For all current Amiga models, Chip memory is set with Instruction
  1399.     caching enabled, data caching disabled.  This prevents coherency
  1400.     conflicts with the blitter or other custom chip DMA.  Custom chip
  1401.     registers are marked as non-cacheable by the hardware.
  1402.  
  1403.     The system takes care of appropriately flushing the caches for normal
  1404.     operations.  The instruction cache is cleared by all calls that
  1405.     modify instructions, including LoadSeg(), MakeLibrary() and
  1406.     SetFunction().
  1407.  
  1408.    SEE ALSO
  1409.     exec/execbase.i, CacheControl, CacheClearU
  1410.  
  1411. exec.library/CacheClearU                             exec.library/CacheClearU
  1412.  
  1413.    NAME
  1414.     CacheClearU - User callable simple cache clearing (V37)
  1415.  
  1416.    SYNOPSIS
  1417.     CacheClearU()
  1418.  
  1419.     void CacheClearU(void);
  1420.  
  1421.    FUNCTION
  1422.     Flush out the contents of any CPU instruction and data caches.
  1423.     If dirty data cache lines are present, push them to memory first.
  1424.  
  1425.     Caches must be cleared after *any* operation that could cause
  1426.     invalid or stale data.  The most common cases are DMA and modifying
  1427.     instructions using the processor.  See the CacheClearE() autodoc
  1428.     for a more complete description.
  1429.  
  1430.     Some examples of when the cache needs clearing:
  1431.             Self modifying code
  1432.             Building Jump tables
  1433.             Run-time code patches
  1434.             Relocating code for use at different addresses.
  1435.             Loading code from disk
  1436.  
  1437.    SEE ALSO
  1438.     exec/execbase.i, CacheControl, CacheClearE
  1439.  
  1440. exec.library/CacheControl                           exec.library/CacheControl
  1441.  
  1442.    NAME
  1443.     CacheControl - Instruction & data cache control
  1444.  
  1445.    SYNOPSIS
  1446.     oldBits = CacheControl(cacheBits,cacheMask)
  1447.     D0                     D0        D1
  1448.  
  1449.     ULONG CacheControl(ULONG,ULONG);
  1450.  
  1451.    FUNCTION
  1452.     This function provides global control of any instruction or data
  1453.     caches that may be connected to the system.  All settings are
  1454.     global -- per task control is not provided.
  1455.  
  1456.     The action taken by this function will depend on the type of
  1457.     CPU installed.  This function may be patched to support external
  1458.     caches, or different cache architectures.  In all cases the function
  1459.     will attempt to best emulate the provided settings.  Use of this
  1460.     function may save state specific to the caches involved.
  1461.  
  1462.     The list of supported settings is provided in the exec/execbase.i
  1463.     include file.  The bits currently defined map directly to the Motorola
  1464.     68030 CPU CACR register.  Alternate cache solutions may patch into
  1465.     the Exec cache functions.  Where possible, bits will be interpreted to
  1466.     have the same meaning on the installed cache.
  1467.  
  1468.    INPUTS
  1469.     cacheBits - new values for the bits specified in cacheMask.
  1470.  
  1471.     cacheMask - a mask with ones for all bits to be changed.
  1472.  
  1473.    RESULT
  1474.     oldBits   - the complete prior values for all settings.
  1475.  
  1476.    NOTE
  1477.     As a side effect, this function clears all caches.
  1478.  
  1479.    SEE ALSO
  1480.     exec/execbase.i, CacheClearU, CacheClearE
  1481.  
  1482. exec.library/CachePostDMA                           exec.library/CachePostDMA
  1483.  
  1484.    NAME
  1485.     CachePostDMA - Take actions after to hardware DMA  (V37)
  1486.  
  1487.    SYNOPSIS
  1488.     CachePostDMA(vaddress,&length,flags)
  1489.                  a0       a1      d0
  1490.  
  1491.     CachePostDMA(APTR,LONG *,ULONG);
  1492.  
  1493.    FUNCTION
  1494.     Take all appropriate steps after Direct Memory Access (DMA).  This
  1495.     function is primarily intended for writers of DMA device drivers.  The
  1496.     action will depend on the CPU type installed, caching modes, and the
  1497.     state of any Memory Management Unit (MMU) activity.
  1498.  
  1499.     As implemented
  1500.         68000 - Do nothing
  1501.         68010 - Do nothing
  1502.         68020 - Do nothing
  1503.         68030 - Flush the data cache
  1504.         68040 - Flush matching areas of the data cache
  1505.         ????? - External cache boards, Virtual Memory Systems, or
  1506.             future hardware may patch this vector to best emulate
  1507.             the intended behavior.
  1508.             With a Bus-Snooping CPU, this function my end up
  1509.             doing nothing.
  1510.  
  1511.    INPUTS
  1512.     address    - Same as initially passed to CachePreDMA
  1513.     length    - Same as initially passed to CachePreDMA
  1514.     flags    - Values:
  1515.             DMA_NoModify - If the area was not modified (and
  1516.             thus there is no reason to flush the cache) set
  1517.             this bit.
  1518.  
  1519.             DMA_ReadFromRAM - Indicates that this DMA is a
  1520.             read from RAM to the DMA device (ie - a write
  1521.             to the hard drive)  This flag is not required
  1522.             but if used must match in both the PreDMA and
  1523.             PostDMA calls.  This flag *should* be used to
  1524.             help the system provide the best performance.
  1525.             This flag is safe in all versions of CachePostDMA()
  1526.  
  1527.    SEE ALSO
  1528.     exec/execbase.i, CachePreDMA, CacheClearU, CacheClearE
  1529.  
  1530. exec.library/CachePreDMA                             exec.library/CachePreDMA
  1531.  
  1532.    NAME
  1533.     CachePreDMA - Take actions prior to hardware DMA  (V37)
  1534.  
  1535.    SYNOPSIS
  1536.     paddress = CachePreDMA(vaddress,&length,flags)
  1537.     d0                     a0       a1      d0
  1538.  
  1539.     APTR CachePreDMA(APTR,LONG *,ULONG);
  1540.  
  1541.    FUNCTION
  1542.     Take all appropriate steps before Direct Memory Access (DMA).  This
  1543.     function is primarily intended for writers of DMA device drivers.  The
  1544.     action will depend on the CPU type installed, caching modes, and the
  1545.     state of any Memory Management Unit (MMU) activity.
  1546.  
  1547.     This function supports advanced cache architectures that have
  1548.     "copyback" modes.  With copyback, write data may be cached, but not
  1549.     actually flushed out to memory.  If the CPU has unflushed data at the
  1550.     time of DMA, data may be lost.
  1551.  
  1552.     As implemented
  1553.         68000 - Do nothing
  1554.         68010 - Do nothing
  1555.         68020 - Do nothing
  1556.         68030 - Do nothing
  1557.         68040 - Write any matching dirty cache lines back to memory.
  1558.             As a side effect of the 68040's design, matching data
  1559.             cache lines are also invalidated -- future CPUs may
  1560.             be different.
  1561.         ????? - External cache boards, Virtual Memory Systems, or
  1562.             future hardware may patch this vector to best emulate
  1563.             the intended behavior.
  1564.             With a Bus-Snooping CPU, this function my end up
  1565.             doing nothing.
  1566.  
  1567.    INPUTS
  1568.     address    - Base address to start the action.
  1569.     length    - Pointer to a longword with a length.
  1570.     flags    - Values:
  1571.             DMA_Continue - Indicates this call is to complete
  1572.             a prior request that was broken up.
  1573.  
  1574.             DMA_ReadFromRAM - Indicates that this DMA is a
  1575.             read from RAM to the DMA device (ie - a write
  1576.             to the hard drive)  This flag is not required
  1577.             but if used must match in both the PreDMA and
  1578.             PostDMA calls.  This flag *should* be used to
  1579.             help the system provide the best performance.
  1580.             This flag is safe in all versions of CachePreDMA()
  1581.  
  1582.    RESULTS
  1583.     paddress- Physical address that corresponds to the input virtual
  1584.           address.
  1585.     &length    - This length value will be updated to reflect the contiguous
  1586.           length of physical memory present at paddress.  This may
  1587.           be smaller than the requested length.  To get the mapping
  1588.           for the next chunk of memory, call the function again with
  1589.           a new address, length, and the DMA_Continue flag.
  1590.  
  1591.    NOTE
  1592.     Due to processor granularity, areas outside of the address range
  1593.     may be affected by the cache flushing actions.  Care has been taken
  1594.     to ensure that no harm is done outside the range, and that activities
  1595.     on overlapping cache lines won't harm data.
  1596.  
  1597.    SEE ALSO
  1598.     exec/execbase.i, CachePostDMA, CacheClearU, CacheClearE
  1599.  
  1600. exec.library/Cause                                         exec.library/Cause
  1601.  
  1602.    NAME
  1603.        Cause -- cause a software interrupt
  1604.  
  1605.    SYNOPSIS
  1606.        Cause(interrupt)
  1607.          A1
  1608.  
  1609.        void Cause(struct Interrupt *);
  1610.  
  1611.    FUNCTION
  1612.     This function causes a software interrupt to occur.  If it is
  1613.     called from user mode (and processor level 0), the software
  1614.     interrupt will preempt the current task.  This call is often used
  1615.     by high-level hardware interrupts to defer medium-length processing
  1616.     down to a lower interrupt level.  Note that a software interrupt is
  1617.     still a real interrupt, and must obey the same restrictions on what
  1618.     system function it may call.
  1619.  
  1620.     Currently only 5 software interrupt priorities are implemented:
  1621.     -32, -16, 0, +16, and +32.  Priorities in between are truncated,
  1622.     values outside the -32/+32 range are not allowed.
  1623.  
  1624.    NOTE
  1625.     When setting up the Interrupt structure, set the node type to
  1626.     NT_INTERRUPT, or NT_UNKOWN.
  1627.  
  1628.    IMPLEMENTATION
  1629.     1> Checks if the node type is NT_SOFTINT.  If so does nothing since
  1630.        the softint is already pending.  No nest count is maintained.
  1631.     2> Sets the node type to NT_SOFTINT.
  1632.     3> Links into one of the 5 priority queues.
  1633.     4> Pokes the hardware interrupt bit used for softints.
  1634.  
  1635.     The node type returns to NT_INTERRUPT after removal from the list.
  1636.  
  1637.    INPUTS
  1638.     interrupt - pointer to a properly initialized interrupt node
  1639.  
  1640.    BUGS
  1641.     Unlike other Interrupts, SoftInts must preserve the value of A6.
  1642.  
  1643. exec.library/CheckIO                                     exec.library/CheckIO
  1644.  
  1645.    NAME
  1646.     CheckIO -- get the status of an IORequest
  1647.  
  1648.    SYNOPSIS
  1649.     result = CheckIO(iORequest)
  1650.     D0         A1
  1651.  
  1652.     struct IORequest *CheckIO(struct IORequest *);
  1653.  
  1654.    FUNCTION
  1655.     This function determines the current state of an I/O request and
  1656.     returns FALSE if the I/O has not yet completed.  This function
  1657.     effectively hides the internals of the I/O completion mechanism.
  1658.  
  1659.     CheckIO() will NOT remove the returned IORequest from the reply port.
  1660.     This is best performed with WaitIO(). If the request has already
  1661.     completed, WaitIO() will return quickly. Use of the Remove()
  1662.     function is dangerous, since other tasks may still be adding things
  1663.     to your message port; a Disable() would be required.
  1664.  
  1665.     This function should NOT be used to busy loop (looping until IO is
  1666.     complete).  WaitIO() is provided for that purpose.
  1667.  
  1668.    INPUTS
  1669.     iORequest - pointer to an I/O request block
  1670.  
  1671.    RESULTS
  1672.     result - NULL if I/O is still in progress.  Otherwise
  1673.          D0 points to the IORequest block.
  1674.  
  1675.    NOTE
  1676.     CheckIO can hang if called on an IORequest that has never been used.
  1677.     This occurs if LN_TYPE of the IORequest is set to "NT_MESSAGE".
  1678.     Instead simply set LN_TYPE to 0.
  1679.  
  1680.    SEE ALSO
  1681.     DoIO, SendIO, WaitIO, AbortIO
  1682.  
  1683. exec.library/CloseDevice                             exec.library/CloseDevice
  1684.  
  1685.    NAME
  1686.     CloseDevice -- conclude access to a device
  1687.  
  1688.    SYNOPSIS
  1689.     CloseDevice(iORequest)
  1690.             A1
  1691.  
  1692.     void CloseDevice(struct IORequest *);
  1693.  
  1694.    FUNCTION
  1695.     This function informs the device that access to a device/unit
  1696.     previously opened has been concluded.  The device may perform
  1697.     certain house-cleaning operations.
  1698.  
  1699.     The user must ensure that all outstanding IORequests have been
  1700.     returned before closing the device.  The AbortIO function can kill
  1701.     any stragglers.
  1702.  
  1703.     After a close, the I/O request structure is free to be reused.
  1704.     Starting with V36 exec it is safe to CloseDevice() with an
  1705.     IORequest that is either cleared to zeros, or failed to
  1706.     open.
  1707.  
  1708.    INPUTS
  1709.     iORequest - pointer to an I/O request structure
  1710.  
  1711.    SEE ALSO
  1712.     OpenDevice
  1713.  
  1714. exec.library/CloseLibrary                           exec.library/CloseLibrary
  1715.  
  1716.    NAME
  1717.     CloseLibrary -- conclude access to a library
  1718.  
  1719.    SYNOPSIS
  1720.     CloseLibrary(library)
  1721.              A1
  1722.  
  1723.     void CloseLibrary(struct Library *);
  1724.  
  1725.    FUNCTION
  1726.     This function informs the system that access to the given library
  1727.     has been concluded.  The user must not reference the library or any
  1728.     function in the library after this close.
  1729.  
  1730.     Starting with V36, it is safe to pass a NULL instead of
  1731.     a library pointer.
  1732.  
  1733.    INPUTS
  1734.     library - pointer to a library node
  1735.  
  1736.    NOTE
  1737.     Library writers must pass a SegList pointer or NULL back from their
  1738.     open point.  This value is used by the system, and not visible as
  1739.     a return code from CloseLibrary.
  1740.  
  1741.    SEE ALSO
  1742.     OpenLibrary
  1743.  
  1744. exec.library/ColdReboot                               exec.library/ColdReboot
  1745.  
  1746.     NAME
  1747.     ColdReboot - reboot the Amiga (V36)
  1748.  
  1749.     SYNOPSIS
  1750.     ColdReboot()
  1751.  
  1752.     void ColdReboot(void);
  1753.  
  1754.     FUNCTION
  1755.     Reboot the machine.  All external memory and periperals will be
  1756.     RESET, and the machine will start its power up diagnostics.
  1757.  
  1758.     This function never returns.
  1759.  
  1760.     INPUT
  1761.     A chaotic pile of disoriented bits.
  1762.  
  1763.     RESULTS
  1764.     An altogether totally integrated living system.
  1765.  
  1766. exec.library/CopyMem                                     exec.library/CopyMem
  1767.  
  1768.    NAME
  1769.     CopyMem - general purpose memory copy function
  1770.  
  1771.    SYNOPSIS
  1772.     CopyMem( source, dest, size )
  1773.          A0     A1    D0
  1774.  
  1775.     void CopyMem(APTR,APTR,ULONG);
  1776.  
  1777.    FUNCTION
  1778.     CopyMem is a general purpose, fast memory copy function.  It can
  1779.     deal with arbitrary lengths, with its pointers on arbitrary
  1780.     alignments.  It attempts to optimize larger copies with more
  1781.     efficient copies, it uses byte copies for small moves, parts of
  1782.     larger copies, or the entire copy if the source and destination are
  1783.     misaligned with respect to each other.
  1784.  
  1785.     Arbitrary overlapping copies are not supported.
  1786.  
  1787.     The internal implementation of this function will change from
  1788.     system to system, and may be implemented via hardware DMA.
  1789.  
  1790.    INPUTS
  1791.     source - a pointer to the source data region
  1792.     dest  - a pointer to the destination data region
  1793.     size  - the size (in bytes) of the memory area.  Zero copies
  1794.         zero bytes
  1795.  
  1796.    SEE ALSO
  1797.     CopyMemQuick
  1798.  
  1799. exec.library/CopyMemQuick                           exec.library/CopyMemQuick
  1800.  
  1801.    NAME
  1802.     CopyMemQuick - optimized memory copy function
  1803.  
  1804.    SYNOPSIS
  1805.     CopyMemQuick( source, dest, size )
  1806.               A0      A1    D0
  1807.  
  1808.     void CopyMemQuick(ULONG *,ULONG *,ULONG);
  1809.  
  1810.    FUNCTION
  1811.     CopyMemQuick is a highly optimized memory copy function, with
  1812.     restrictions on the size and alignment of its arguments. Both the
  1813.     source and destination pointers must be longword aligned.  In
  1814.     addition, the size must be an integral number of longwords (e.g.
  1815.     the size must be evenly divisible by four).
  1816.  
  1817.     Arbitrary overlapping copies are not supported.
  1818.  
  1819.     The internal implementation of this function will change from system
  1820.     to system, and may be implemented via hardware DMA.
  1821.  
  1822.    INPUTS
  1823.     source - a pointer to the source data region, long aligned
  1824.     dest -  a pointer to the destination data region, long aligned
  1825.     size -  the size (in bytes) of the memory area.  Zero copies
  1826.         zero bytes.
  1827.  
  1828.    SEE ALSO
  1829.     CopyMem
  1830.  
  1831. exec.library/CreateIORequest                     exec.library/CreateIORequest
  1832.  
  1833.    NAME
  1834.     CreateIORequest() -- create an IORequest structure  (V36)
  1835.  
  1836.    SYNOPSIS
  1837.     ioReq = CreateIORequest( ioReplyPort, size );
  1838.                              A0           D0
  1839.  
  1840.     struct IORequest *CreateIORequest(struct MsgPort *, ULONG);
  1841.  
  1842.    FUNCTION
  1843.     Allocates memory for and initializes a new IO request block
  1844.     of a user-specified number of bytes.  The number of bytes
  1845.     must be at least as large as a "struct Message".
  1846.  
  1847.    INPUTS
  1848.     ioReplyPort - Pointer to a port for replies (an initialized message
  1849.         port, as created by CreateMsgPort() ).  If NULL, this
  1850.         function fails.
  1851.     size - the size of the IO request to be created.
  1852.  
  1853.    RESULT
  1854.     ioReq - A pointer to the new IORequest block, or NULL.
  1855.  
  1856.    SEE ALSO
  1857.     DeleteIORequest, CreateMsgPort(), amiga.lib/CreateExtIO()
  1858.  
  1859. exec.library/CreateMsgPort                         exec.library/CreateMsgPort
  1860.  
  1861.    NAME
  1862.     CreateMsgPort - Allocate and initialize a new message port  (V36)
  1863.  
  1864.    SYNOPSIS
  1865.     CreateMsgPort()
  1866.  
  1867.     struct MsgPort * CreateMsgPort(void);
  1868.  
  1869.    FUNCTION
  1870.     Allocates and initializes a new message port.  The message list
  1871.     of the new port will be prepared for use (via NewList).  A signal
  1872.     bit will be allocated, and the port will be set to signal your
  1873.     task when a message arrives (PA_SIGNAL).
  1874.  
  1875.     You *must* use DeleteMsgPort() to delete ports created with
  1876.     CreateMsgPort()!
  1877.  
  1878.    RESULT
  1879.     MsgPort - A new MsgPort structure ready for use, or NULL if out of
  1880.         memory or signals.  If you wish to add this port to the public
  1881.         port list, fill in the ln_Name and ln_Pri fields, then call
  1882.         AddPort().  Don't forget RemPort()!
  1883.  
  1884.    SEE ALSO
  1885.     DeleteMsgPort(), exec/AddPort(), exec/ports.h, amiga.lib/CreatePort()
  1886.  
  1887. exec.library/CreatePool                               exec.library/CreatePool
  1888.  
  1889.     NAME
  1890.     CreatePool -- Generate a private memory pool header (V39)
  1891.  
  1892.     SYNOPSIS
  1893.     newPool=CreatePool(memFlags,puddleSize,threshSize)
  1894.     a0                 d0       d1         d2
  1895.  
  1896.     void *CreatePool(ULONG,ULONG,ULONG);
  1897.  
  1898.     FUNCTION
  1899.     Allocate and prepare a new memory pool header.    Each pool is a
  1900.     separate tracking system for memory of a specific type.  Any number
  1901.     of pools may exist in the system.
  1902.  
  1903.     Pools automatically expand and shrink based on demand.    Fixed sized
  1904.     "puddles" are allocated by the pool manager when more total memory
  1905.     is needed.  Many small allocations can fit in a single puddle.
  1906.     Allocations larger than the threshSize are allocation in their own
  1907.     puddles.
  1908.  
  1909.     At any time individual allocations may be freed.  Or, the entire
  1910.     pool may be removed in a single step.
  1911.  
  1912.     INPUTS
  1913.     memFlags - a memory flags specifier, as taken by AllocMem.
  1914.     puddleSize - the size of Puddles...
  1915.     threshSize - the largest allocation that goes into normal puddles
  1916.                  This *MUST* be less than or equal to puddleSize
  1917.                  (CreatePool() will fail if it is not)
  1918.  
  1919.     RESULT
  1920.     The address of a new pool header, or NULL for error.
  1921.  
  1922.     SEE ALSO
  1923.     DeletePool(), AllocPooled(), FreePooled(), exec/memory.i
  1924.  
  1925. exec.library/Deallocate                               exec.library/Deallocate
  1926.  
  1927.    NAME
  1928.     Deallocate -- deallocate a block of memory
  1929.  
  1930.    SYNOPSIS
  1931.     Deallocate(memHeader, memoryBlock, byteSize)
  1932.            A0          A1       D0
  1933.  
  1934.     void Deallocate(struct MemHeader *,APTR,ULONG);
  1935.  
  1936.    FUNCTION
  1937.     This function deallocates memory by returning it to the appropriate
  1938.     private free memory pool.  This function can be used to free an
  1939.     entire block allocated with the above function, or it can be used
  1940.     to free a sub-block of a previously allocated block.  Sub-blocks
  1941.     must be an even multiple of the memory chunk size (currently 8
  1942.     bytes).
  1943.  
  1944.     This function can even be used to add a new free region to an
  1945.     existing MemHeader, however the extent pointers in the MemHeader
  1946.     will no longer be valid.
  1947.  
  1948.     If memoryBlock is not on a block boundary (MEM_BLOCKSIZE) then it
  1949.     will be rounded down in a manner compatible with Allocate().  Note
  1950.     that this will work correctly with all the memory allocation
  1951.     functions, but may cause surprises if one is freeing only part of a
  1952.     region.  The size of the block will be rounded up, so the freed
  1953.     block will fill to an even memory block boundary.
  1954.  
  1955.    INPUTS
  1956.     memHeader - points to the memory header this block is part of.
  1957.     memoryBlock - address of memory block to free.
  1958.     byteSize - the size of the block in bytes. If NULL, nothing
  1959.            happens.
  1960.  
  1961.    SEE ALSO
  1962.     Allocate, exec/memory.h
  1963.  
  1964. exec.library/Debug                                         exec.library/Debug
  1965.  
  1966.    NAME
  1967.     Debug -- run the system debugger
  1968.  
  1969.    SYNOPSIS
  1970.     Debug(flags)
  1971.           D0
  1972.  
  1973.     void Debug(ULONG);
  1974.  
  1975.    FUNCTION
  1976.     This function calls the system debugger.  By default this debugger
  1977.     is "SAD" in >= V39 and "ROM-WACK" in < V39.  Other debuggers are
  1978.     encouraged to take over this entry point (via SetFunction()) so
  1979.     that when an application calls Debug(), the alternative debugger
  1980.     will get control.  Currently a zero is passed to allow future
  1981.     expansion.
  1982.  
  1983.    NOTE
  1984.     The Debug() call may be made when the system is in a questionable
  1985.     state; if you have a SetFunction() patch, make few assumptions, be
  1986.     prepared for Supervisor mode, and be aware of differences in the
  1987.     Motorola stack frames on the 68000,'10,'20,'30,'40 (etc.)
  1988.  
  1989.    BUGS
  1990.     In ROMWack, calling this function in SUPERVISOR state would have
  1991.     caused the a5 register to be trashed and the user stack pointer to
  1992.     be trashed.  As of V39 (and the instroduction of SAD) this is no
  1993.     longer the case.  However, calling this function in Supervisor
  1994.     state is a bit "tricky" at best...
  1995.  
  1996.     Note that due to a bug, pre-V40 SAD had the command
  1997.     codes wrong.  See the SAD autodoc for more details.
  1998.  
  1999.    SEE ALSO
  2000.     SetFunction()
  2001.     your favorite debugger's manual...
  2002.     the SAD autodocs...
  2003.     the ROM-WACK chapter of the ROM Kernel Manual... (pre-V39)
  2004.  
  2005. exec.library/DeleteIORequest                     exec.library/DeleteIORequest
  2006.  
  2007.    NAME
  2008.     DeleteIORequest() - Free a request made by CreateIORequest()  (V36)
  2009.  
  2010.    SYNOPSIS
  2011.     DeleteIORequest( ioReq );
  2012.                      a0
  2013.  
  2014.     void DeleteIORequest(struct IORequest *);
  2015.  
  2016.    FUNCTION
  2017.     Frees up an IO request as allocated by CreateIORequest().
  2018.  
  2019.    INPUTS
  2020.     ioReq - A pointer to the IORequest block to be freed, or NULL.
  2021.         This function uses the mn_Length field to determine how
  2022.         much memory to free.
  2023.  
  2024.    SEE ALSO
  2025.     CreateIORequest(), amiga.lib/DeleteExtIO()
  2026.  
  2027. exec.library/DeleteMsgPort                         exec.library/DeleteMsgPort
  2028.  
  2029.    NAME
  2030.     DeleteMsgPort - Free a message port created by CreateMsgPort  (V36)
  2031.  
  2032.    SYNOPSIS
  2033.     DeleteMsgPort(msgPort)
  2034.               a0
  2035.  
  2036.     void DeleteMsgPort(struct MsgPort *);
  2037.  
  2038.    FUNCTION
  2039.     Frees a message port created by CreateMsgPort().  All messages that
  2040.     may have been attached to this port must have already been
  2041.     replied to.
  2042.  
  2043.    INPUTS
  2044.     msgPort - A message port.  NULL for no action.
  2045.  
  2046.    SEE ALSO
  2047.     CreateMsgPort(), amiga.lib/DeletePort()
  2048.  
  2049. exec.library/DeletePool                               exec.library/DeletePool
  2050.  
  2051.     NAME
  2052.     DeletePool --  Drain an entire memory pool (V39)
  2053.  
  2054.     SYNOPSIS
  2055.     DeletePool(poolHeader)
  2056.                a0
  2057.  
  2058.     void DeletePool(void *);
  2059.  
  2060.     FUNCTION
  2061.     Frees all memory in all pudles of the specified pool header, then
  2062.     deletes the pool header.  Individual free calls are not needed.
  2063.  
  2064.     INPUTS
  2065.     poolHeader - as returned by CreatePool().
  2066.  
  2067.     SEE ALSO
  2068.     CreatePool(), AllocPooled(), FreePooled()
  2069.  
  2070. exec.library/Disable                                     exec.library/Disable
  2071.  
  2072.     NAME
  2073.     Disable -- disable interrupt processing.
  2074.  
  2075.     SYNOPSIS
  2076.     Disable();
  2077.  
  2078.     void Disable(void);
  2079.  
  2080.     FUNCTION
  2081.     Prevents interrupts from being handled by the system, until a
  2082.     matching Enable() is executed.  Disable() implies Forbid().
  2083.  
  2084.     DO NOT USE THIS CALL WITHOUT GOOD JUSTIFICATION.  THIS CALL IS
  2085.     VERY DANGEROUS!
  2086.  
  2087.     RESULTS
  2088.     All interrupt processing is deferred until the task executing makes
  2089.     a call to Enable() or is placed in a wait state.  Normal task
  2090.     rescheduling does not occur while interrupts are disabled.  In order
  2091.     to restore normal interrupt processing, the programmer must execute
  2092.     exactly one call to Enable() for every call to Disable().
  2093.  
  2094.     IMPORTANT REMINDER:
  2095.  
  2096.     It is important to remember that there is a danger in using
  2097.     disabled sections.  Disabling interrupts for more than ~250
  2098.     microseconds will prevent vital system functions (especially serial
  2099.     I/0) from operating in a normal fashion.
  2100.  
  2101.     Think twice before using Disable(), then think once more.
  2102.     After all that, think again.  With enough thought, the need
  2103.     for a Disable() can often be eliminated.  For the user of many
  2104.     device drivers, a write to disable *only* the particular interrupt
  2105.     of interest can replace a Disable().  For example:
  2106.             MOVE.W    #INTF_PORTS,_intena
  2107.     Do not use a macro for Disable(), insist on the real thing.
  2108.  
  2109.     This call may be made from interrupts, it will have the effect
  2110.     of locking out all higher-level interrupts (lower-level interrupts
  2111.     are automatically disabled by the CPU).
  2112.  
  2113.         Note: In the event of a task entering a Wait() after disabling
  2114.               interrupts, the system "breaks" the disabled state and runs
  2115.               normally until the task which called Disable() is rescheduled.
  2116.  
  2117.     NOTE
  2118.     This call is guaranteed to preserve all registers.
  2119.  
  2120.     SEE ALSO
  2121.     Forbid, Permit, Enable
  2122.  
  2123. exec.library/DoIO                                           exec.library/DoIO
  2124.  
  2125.    NAME
  2126.     DoIO -- perform an I/O command and wait for completion
  2127.  
  2128.    SYNOPSIS
  2129.     error = DoIO(iORequest)
  2130.     D0         A1
  2131.  
  2132.     BYTE DoIO(struct IORequest *);
  2133.  
  2134.    FUNCTION
  2135.     This function requests a device driver to perform the I/O command
  2136.     specified in the I/O request.  This function will always wait until
  2137.     the I/O request is fully complete.
  2138.  
  2139.     DoIO() handles all the details, including Quick I/O, waiting for
  2140.     the request, and removing the reply message, etc..
  2141.  
  2142.    IMPLEMENTATION
  2143.     This function first tries to complete the IO via the "Quick I/O"
  2144.     mechanism.  The io_Flags field is always set to IOF_QUICK (0x01)
  2145.     before the internal device call.
  2146.  
  2147.     The LN_TYPE field is used internally to flag completion.  Active
  2148.     requests have type NT_MESSAGE.  Requests that have been replied
  2149.     have type NT_REPLYMSG.  It is illegal to start IO using a
  2150.     still active IORequest, or a request with type NT_REPLYMSG.
  2151.  
  2152.    INPUTS
  2153.     iORequest - pointer to an IORequest initialized by OpenDevice()
  2154.  
  2155.    RESULTS
  2156.     error - a sign-extended copy of the io_Error field of the
  2157.         IORequest.  Most device commands require that the error
  2158.         return be checked.
  2159.  
  2160.    SEE ALSO
  2161.     SendIO, CheckIO, WaitIO, AbortIO, amiga.lib/BeginIO
  2162.  
  2163. exec.library/Enable                                       exec.library/Enable
  2164.  
  2165.    NAME
  2166.     Enable -- permit system interrupts to resume.
  2167.  
  2168.    SYNOPSIS
  2169.     Enable();
  2170.  
  2171.     void Enable(void);
  2172.  
  2173.    FUNCTION
  2174.     Allow system interrupts to again occur normally, after a matching
  2175.     Disable() has been executed.
  2176.  
  2177.    RESULTS
  2178.     Interrupt processing is restored to normal operation. The
  2179.     programmer must execute exactly one call to Enable() for every call
  2180.     to Disable().
  2181.  
  2182.     NOTE
  2183.     This call is guaranteed to preserve all registers.
  2184.  
  2185.    SEE ALSO
  2186.     Forbid, Permit, Disable
  2187.  
  2188.  
  2189. exec.library/Enqueue                                     exec.library/Enqueue
  2190.  
  2191.    NAME
  2192.     Enqueue -- insert or append node to a system queue
  2193.  
  2194.    SYNOPSIS
  2195.     Enqueue(list, node)
  2196.         A0    A1
  2197.  
  2198.     void Enqueue(struct List *, struct Node *);
  2199.  
  2200.    FUNCTION
  2201.     Insert or append a node into a system queue.  The insert is
  2202.     performed based on the node priority -- it will keep the list
  2203.     properly sorted.  New nodes will be inserted in front of the first
  2204.     node with a lower priority.   Hence a FIFO queue for nodes of equal
  2205.     priority
  2206.  
  2207.    WARNING
  2208.     This function does not arbitrate for access to the list.  The
  2209.     calling task must be the owner of the involved list.
  2210.  
  2211.    INPUTS
  2212.     list - a pointer to the system queue header
  2213.     node - the node to enqueue.  This must be a full featured node
  2214.            with type, priority and name fields.
  2215.  
  2216.    SEE ALSO
  2217.     AddHead, AddTail, Insert, Remove, RemHead, RemTail
  2218.  
  2219. exec.library/FindName                                   exec.library/FindName
  2220.  
  2221.    NAME
  2222.     FindName -- find a system list node with a given name
  2223.  
  2224.    SYNOPSIS
  2225.     node = FindName(start, name)
  2226.     D0,Z        A0     A1
  2227.  
  2228.     struct Node *FindName(struct List *, STRPTR);
  2229.  
  2230.    FUNCTION
  2231.     Traverse a system list until a node with the given name is found.
  2232.     To find multiple occurrences of a string, this function may be
  2233.     called with a node starting point.
  2234.  
  2235.     No arbitration is done for access to the list!    If multiple tasks
  2236.     access the same list, an arbitration mechanism such as
  2237.     SignalSemaphores must be used.
  2238.  
  2239.    INPUTS
  2240.     start - a list header or a list node to start the search
  2241.         (if node, this one is skipped)
  2242.     name - a pointer to a name string terminated with NULL
  2243.  
  2244.    RESULTS
  2245.     node - a pointer to the node with the same name else
  2246.         zero to indicate that the string was not found.
  2247.  
  2248. exec.library/FindPort                                   exec.library/FindPort
  2249.  
  2250.    NAME
  2251.     FindPort -- find a given system message port
  2252.  
  2253.    SYNOPSIS
  2254.     port = FindPort(name)
  2255.     D0        A1
  2256.  
  2257.     struct MsgPort *FindPort(STRPTR);
  2258.  
  2259.    FUNCTION
  2260.     This function will search the system message port list for a port
  2261.     with the given name.  The first port matching this name will be
  2262.     returned.  No arbitration of the port list is done.  This function
  2263.     MUST be protected with A Forbid()/Permit() pair!
  2264.  
  2265.    EXAMPLE
  2266.     #include <exec/types.h>
  2267.     struct MsgPort *FindPort();
  2268.  
  2269.     ULONG SafePutToPort(message, portname)
  2270.     struct Message *message;
  2271.     STRPTR          portname;
  2272.     {
  2273.     struct MsgPort *port;
  2274.  
  2275.         Forbid();
  2276.         port = FindPort(portname);
  2277.         if (port)
  2278.             PutMsg(port,message);
  2279.         Permit();
  2280.         return((ULONG)port); /* If zero, the port has gone away */
  2281.     }
  2282.  
  2283.    INPUT
  2284.     name - name of the port to find
  2285.  
  2286.    RETURN
  2287.     port - a pointer to the message port, or zero if
  2288.         not found.
  2289.  
  2290.  
  2291. exec.library/FindResident                           exec.library/FindResident
  2292.  
  2293.    NAME
  2294.     FindResident - find a resident module by name
  2295.  
  2296.    SYNOPSIS
  2297.     resident = FindResident(name)
  2298.     D0            A1
  2299.  
  2300.     struct Resident *FindResident(STRPTR);
  2301.  
  2302.    FUNCTION
  2303.     Search the system resident tag list for a resident tag ("ROMTag") with
  2304.     the given name.  If found return a pointer to the resident tag
  2305.     structure, else return zero.
  2306.  
  2307.     Resident modules are used by the system to pull all its parts
  2308.     together at startup.  Resident tags are also found in disk based
  2309.     devices and libraries.
  2310.  
  2311.    INPUTS
  2312.     name - pointer to name string
  2313.  
  2314.    RESULT
  2315.     resident - pointer to the resident tag structure or
  2316.         zero if none found.
  2317.  
  2318.     SEE ALSO
  2319.     exec/resident.h, InitResident
  2320.  
  2321. exec.library/FindSemaphore                         exec.library/FindSemaphore
  2322.  
  2323.    NAME
  2324.     FindSemaphore -- find a given system signal semaphore
  2325.  
  2326.    SYNOPSIS
  2327.     signalSemaphore = FindSemaphore(name)
  2328.     D0                        A1
  2329.  
  2330.     struct SignalSemaphore *FindSemaphore(STRPTR);
  2331.  
  2332.    FUNCTION
  2333.     This function will search the system signal semaphore list for a
  2334.     semaphore with the given name.    The first semaphore matching this
  2335.     name will be returned.
  2336.  
  2337.     This function does not arbitrate for access to the semaphore list,
  2338.     surround the call with a Forbid()/Permit() pair.
  2339.  
  2340.    INPUT
  2341.     name - name of the semaphore to find
  2342.  
  2343.    RESULT
  2344.     semaphore - a pointer to the signal semaphore, or zero if not
  2345.             found.
  2346.  
  2347. exec.library/FindTask                                   exec.library/FindTask
  2348.  
  2349.    NAME
  2350.     FindTask -- find a task with the given name or find oneself
  2351.  
  2352.    SYNOPSIS
  2353.     task = FindTask(name)
  2354.     D0        A1
  2355.  
  2356.     struct Task *FindTask(STRPTR);
  2357.  
  2358.    FUNCTION
  2359.     This function will check all task queues for a task with the given
  2360.     name, and return a pointer to its task control block.  If a NULL
  2361.     name pointer is given a pointer to the current task will be
  2362.     returned.
  2363.  
  2364.     Finding oneself with a NULL for the name is very quick.  Finding a
  2365.     task by name is very system expensive, and will disable interrupts
  2366.     for a long time.  Since a task may remove itself at any time,
  2367.     a Forbid()/Permit() pair may be needed to ensure the pointer
  2368.     returned by FindTask() is still valid when used.
  2369.  
  2370.    INPUT
  2371.     name - pointer to a name string
  2372.  
  2373.    RESULT
  2374.     task - pointer to the task (or Process)
  2375.  
  2376. exec.library/Forbid                                       exec.library/Forbid
  2377.  
  2378.     NAME
  2379.     Forbid -- forbid task rescheduling.
  2380.  
  2381.     SYNOPSIS
  2382.     Forbid()
  2383.  
  2384.     void Forbid(void);
  2385.  
  2386.     FUNCTION
  2387.     Prevents other tasks from being scheduled to run by the dispatcher,
  2388.     until a matching Permit() is executed, or this task is scheduled to
  2389.     Wait().  Interrupts are NOT disabled.
  2390.  
  2391.     DO NOT USE THIS CALL WITHOUT GOOD JUSTIFICATION.  THIS CALL IS
  2392.     DANGEROUS!
  2393.  
  2394.     RESULTS
  2395.     The current task will not be rescheduled as long as it is ready to
  2396.     run.  In the event that the current task enters a wait state, other
  2397.     tasks may be scheduled.  Upon return from the wait state, the original
  2398.     task will continue to run without disturbing the Forbid().
  2399.  
  2400.     Calls to Forbid() nest. In order to restore normal task rescheduling,
  2401.     the programmer must execute exactly one call to Permit() for every
  2402.     call to Forbid().
  2403.  
  2404.     WARNING
  2405.     In the event of a task entering a Wait() after a Forbid(), the system
  2406.     "breaks" the forbidden state and runs normally until the task which
  2407.     called Forbid() is rescheduled.  If caution is not taken, this can
  2408.     cause subtle bugs, since any device or DOS call will (in effect)
  2409.     cause your task to wait.
  2410.  
  2411.     Forbid() is not useful or safe from within interrupt code
  2412.     (All interrupts are always higher priority than tasks, and
  2413.     interrupts are allowed to break a Forbid()).
  2414.  
  2415.     NOTE
  2416.     This call is guaranteed to preserve all registers.
  2417.  
  2418.     SEE ALSO
  2419.     Permit, Disable, ObtainSemaphore, ObtainSemaphoreShared
  2420.  
  2421. exec.library/FreeEntry                                 exec.library/FreeEntry
  2422.  
  2423.    NAME
  2424.     FreeEntry -- free many regions of memory
  2425.  
  2426.    SYNOPSIS
  2427.     FreeEntry(memList)
  2428.           A0
  2429.     void FreeEntry(struct MemList *);
  2430.  
  2431.    FUNCTION
  2432.     This function takes a memList structure (as returned by AllocEntry)
  2433.     and frees all the entries.
  2434.  
  2435.    INPUTS
  2436.     memList -- pointer to structure filled in with MemEntry
  2437.            structures
  2438.  
  2439.    SEE ALSO
  2440.     AllocEntry
  2441.  
  2442. exec.library/FreeMem                                     exec.library/FreeMem
  2443.  
  2444.    NAME
  2445.     FreeMem -- deallocate with knowledge
  2446.  
  2447.    SYNOPSIS
  2448.     FreeMem(memoryBlock, byteSize)
  2449.         A1         D0
  2450.  
  2451.     void FreeMem(void *,ULONG);
  2452.  
  2453.    FUNCTION
  2454.     Free a region of memory, returning it to the system pool from which
  2455.     it came.  Freeing partial blocks back into the system pool is
  2456.     unwise.
  2457.  
  2458.    NOTE
  2459.     If a block of memory is freed twice, the system will Guru. The
  2460.     Alert is AN_FreeTwice ($01000009).   If you pass the wrong pointer,
  2461.     you will probably see AN_MemCorrupt $01000005.  Future versions may
  2462.     add more sanity checks to the memory lists.
  2463.  
  2464.    INPUTS
  2465.     memoryBlock - pointer to the memory block to free
  2466.     byteSize - the size of the desired block in bytes.  (The operating
  2467.         system will automatically round this number to a multiple of
  2468.         the system memory chunk size)
  2469.  
  2470.    SEE ALSO
  2471.     AllocMem
  2472.  
  2473. exec.library/FreePooled                               exec.library/FreePooled
  2474.  
  2475.     NAME
  2476.     FreePooled -- Free pooled memory  (V39)
  2477.  
  2478.     SYNOPSIS
  2479.     FreePooled(poolHeader,memory,memSize)
  2480.            a0         a1     d0
  2481.  
  2482.     void FreePooled(void *,void *,ULONG);
  2483.  
  2484.     FUNCTION
  2485.     Deallocates memory allocated by AllocPooled().  The size of the
  2486.     allocation *MUST* match the size given to AllocPooled().
  2487.     The reason the pool functions do not track individual allocation
  2488.     sizes is because many of the uses of pools have small allocation
  2489.     sizes and the tracking of the size would be a large overhead.
  2490.  
  2491.     Only memory allocated by AllocPooled() may be freed with this
  2492.     function!
  2493.  
  2494.     Doing a DeletePool() on the pool will free all of the puddles
  2495.     and thus all of the allocations done with AllocPooled() in that
  2496.     pool.  (No need to FreePooled() each allocation)
  2497.  
  2498.     INPUTS
  2499.     memory - pointer to memory allocated by AllocPooled.
  2500.     poolHeader - a specific private pool header.
  2501.  
  2502.     NOTES
  2503.     The pool function do not protect an individual pool from
  2504.     multiple accesses.  The reason is that in most cases the pools
  2505.     will be used by a single task.  If your pool is going to
  2506.     be used by more than one task you must Semaphore protect
  2507.     the pool from having more than one task trying to allocate
  2508.     within the same pool at the same time.  Warning:  Forbid()
  2509.     protection *will not work* in the future.  *Do NOT* assume
  2510.     that we will be able to make it work in the future.  FreePooled()
  2511.     may well break a Forbid() and as such can only be protected
  2512.     by a semaphore.
  2513.  
  2514.     To track sizes yourself, the following code can be used:
  2515.     Assumes a6=ExecBase
  2516.  
  2517.     ;
  2518.     ; Function to do AllocVecPooled(Pool,memSize)
  2519.     ;
  2520.     AllocVecPooled:    addq.l    #4,d0        ; Get space for tracking
  2521.             move.l    d0,-(sp)    ; Save the size
  2522.             jsr    _LVOAllocPooled(a6)    ; Call pool...
  2523.             move.l    (sp)+,d1    ; Get size back...
  2524.             tst.l    d0        ; Check for error
  2525.             beq.s    avp_fail    ; If NULL, failed!
  2526.             move.l    d0,a0        ; Get pointer...
  2527.             move.l    d1,(a0)+    ; Store size
  2528.             move.l    a0,d0        ; Get result
  2529.     avp_fail:    rts            ; return
  2530.  
  2531.     ;
  2532.     ; Function to do FreeVecPooled(pool,memory)
  2533.     ;
  2534.     FreeVecPooled:    move.l    -(a1),d0    ; Get size / ajust pointer
  2535.             jmp    _LVOFreePooled(a6)
  2536.  
  2537.     SEE ALSO
  2538.     AllocPooled(), CreatePool(), DeletePool()
  2539.  
  2540. exec.library/FreeSignal                               exec.library/FreeSignal
  2541.  
  2542.    NAME
  2543.     FreeSignal -- free a signal bit
  2544.  
  2545.    SYNOPSIS
  2546.     FreeSignal(signalNum)
  2547.            D0
  2548.  
  2549.     void FreeSignal(BYTE);
  2550.  
  2551.    FUNCTION
  2552.     This function frees a previously allocated signal bit for reuse.
  2553.     This call must be performed while running in the same task in which
  2554.     the signal was allocated.
  2555.  
  2556.    WARNING
  2557.     Signals may not be allocated or freed from exception handling code.
  2558.  
  2559.    NOTE
  2560.     Starting with V37, an attempt to free signal -1 is harmless.
  2561.  
  2562.    INPUTS
  2563.     signalNum - the signal number to free {0..31}.
  2564.  
  2565. exec.library/FreeTrap                                   exec.library/FreeTrap
  2566.  
  2567.    NAME
  2568.     FreeTrap -- free a processor trap
  2569.  
  2570.    SYNOPSIS
  2571.     FreeTrap(trapNum)
  2572.          D0
  2573.  
  2574.     void FreeTrap(ULONG);
  2575.  
  2576.    FUNCTION
  2577.     This function frees a previously allocated trap number for reuse.
  2578.     This call must be performed while running in the same task in which
  2579.     the trap was allocated.
  2580.  
  2581.    WARNING
  2582.     Traps may not be allocated or freed from exception handling code.
  2583.  
  2584.    INPUTS
  2585.     trapNum - the trap number to free {of 0..15}
  2586.  
  2587. exec.library/FreeVec                                     exec.library/FreeVec
  2588.  
  2589.    NAME
  2590.     FreeVec -- return AllocVec() memory to the system  (V36)
  2591.  
  2592.    SYNOPSIS
  2593.     FreeVec(memoryBlock)
  2594.         A1
  2595.  
  2596.     void FreeVec(void *);
  2597.  
  2598.    FUNCTION
  2599.     Free an allocation made by the AllocVec() call.  The memory will
  2600.     be returned to the system pool from which it came.
  2601.  
  2602.    NOTE
  2603.     If a block of memory is freed twice, the system will Guru. The
  2604.     Alert is AN_FreeTwice ($01000009).   If you pass the wrong pointer,
  2605.     you will probably see AN_MemCorrupt $01000005.  Future versions may
  2606.     add more sanity checks to the memory lists.
  2607.  
  2608.    INPUTS
  2609.     memoryBlock - pointer to the memory block to free, or NULL.
  2610.  
  2611.    SEE ALSO
  2612.     AllocVec
  2613.  
  2614. exec.library/GetCC                                         exec.library/GetCC
  2615.  
  2616.    NAME
  2617.     GetCC -- get condition codes in a 68010 compatible way.
  2618.  
  2619.    SYNOPSIS
  2620.     conditions = GetCC()
  2621.       D0
  2622.  
  2623.     UWORD GetCC(void);
  2624.  
  2625.    FUNCTION
  2626.     The 68000 processor has a "MOVE SR,<ea>" instruction which gets a
  2627.     copy of the processor condition codes.
  2628.  
  2629.     On the 68010,20 and 30 CPUs, "MOVE SR,<ea>" is privileged.  User
  2630.     code will trap if it is attempted.  These processors need to use
  2631.     the "MOVE CCR,<ea>" instruction instead.
  2632.  
  2633.     This function provides a means of obtaining the CPU condition codes
  2634.     in a manner that will make upgrades transparent.  This function is
  2635.     VERY short and quick.
  2636.  
  2637.    RESULTS
  2638.     conditions - the 680XX condition codes
  2639.  
  2640.     NOTE
  2641.     This call is guaranteed to preserve all registers.  This function
  2642.     may be implemented as code right in the jump table.
  2643.  
  2644. exec.library/GetMsg                                       exec.library/GetMsg
  2645.  
  2646.    NAME
  2647.     GetMsg -- get next message from a message port
  2648.  
  2649.    SYNOPSIS
  2650.     message = GetMsg(port)
  2651.     D0         A0
  2652.  
  2653.     struct Message *GetMsg(struct MsgPort *);
  2654.  
  2655.    FUNCTION
  2656.     This function receives a message from a given message port. It
  2657.     provides a fast, non-copying message receiving mechanism. The
  2658.     received message is removed from the message port.
  2659.  
  2660.     This function will not wait.  If a message is not present this
  2661.     function will return zero.  If a program must wait for a message,
  2662.     it can Wait() on the signal specified for the port or use the
  2663.     WaitPort() function.  There can only be one task waiting for any
  2664.     given port.
  2665.  
  2666.     Getting a message does not imply to the sender that the message is
  2667.     free to be reused by the sender.  When the receiver is finished
  2668.     with the message, it may ReplyMsg() it back to the sender.
  2669.  
  2670.  
  2671.     Getting a signal does NOT always imply a message is ready.  More
  2672.     than one message may arrive per signal, and signals may show up
  2673.     without messages.  Typically you must loop to GetMsg() until it
  2674.     returns zero, then Wait() or WaitPort().
  2675.  
  2676.    INPUT
  2677.     port - a pointer to the receiver message port
  2678.  
  2679.    RESULT
  2680.     message - a pointer to the first message available.  If
  2681.           there are no messages, return zero.
  2682.           Callers must be prepared for zero at any time.
  2683.  
  2684.    SEE ALSO
  2685.     PutMsg, ReplyMsg, WaitPort, Wait, exec/ports.h
  2686.  
  2687. exec.library/InitCode                                   exec.library/InitCode
  2688.  
  2689.    NAME
  2690.     InitCode - initialize resident code modules (internal function)
  2691.  
  2692.    SYNOPSIS
  2693.     InitCode(startClass, version)
  2694.          D0          D1
  2695.  
  2696.     void InitCode(ULONG,ULONG);
  2697.  
  2698.    FUNCTION
  2699.     (This function may be ignored by application programmers)
  2700.  
  2701.     Call InitResident() for all resident modules in the ResModules array
  2702.     with the given startClass and with versions equal or greater than
  2703.     that specified.  The segList parameter is passed as zero.
  2704.  
  2705.     Resident modules are used by the system to pull all its parts
  2706.     together at startup.  Modules are initialized in a prioritized order.
  2707.  
  2708.     Modules that do not have a startclass should be of priority -120.
  2709.     RTF_AFTERDOS modules should start at -100 (working down).
  2710.  
  2711.    INPUTS
  2712.     startClass - the class of code to be initialized:
  2713.         BITDEF RT,COLDSTART,0
  2714.         BITDEF RT,SINGLETASK,1    ;ExecBase->ThisTask==0 (V36 only)
  2715.         BITDEF RT,AFTERDOS,2    ;(V36 only)
  2716.     version - a major version number
  2717.  
  2718.     SEE ALSO
  2719.     ResidentTag (RT) structure definition (resident.h)
  2720.  
  2721. exec.library/InitResident                           exec.library/InitResident
  2722.  
  2723.    NAME
  2724.     InitResident - initialize resident module
  2725.  
  2726.    SYNOPSIS
  2727.     object = InitResident(resident, segList)
  2728.     D0                   A1        D1
  2729.  
  2730.     APTR InitResident(struct Resident *,ULONG);
  2731.  
  2732.    FUNCTION
  2733.     Initialize a ROMTag.  ROMTags are used to link system modules
  2734.     together.  Each disk based device or library must contain a
  2735.     ROMTag structure in the first code hunk.
  2736.  
  2737.     Once the validity of the ROMTag is verified, the RT_INIT pointer
  2738.     is jumped to  with the following registers:
  2739.         D0 = 0
  2740.         A0 = segList
  2741.          A6 = ExecBase
  2742.  
  2743.    INPUTS
  2744.     resident - Pointer to a ROMTag
  2745.     segList  - SegList of the loaded object, if loaded from disk.
  2746.            Libraries & Devices will cache this value for later
  2747.            return at close or expunge time.  Pass NULL for ROM
  2748.            modules.
  2749.  
  2750.    RESULTS
  2751.     object    - Return value from the init code, usually the library
  2752.           or device base.  NULL for failure.
  2753.  
  2754.    AUTOINIT FEATURE
  2755.     An automatic method of library/device base and vector table
  2756.     initialization is also provided by InitResident().  The initial code
  2757.     hunk of the library or device should contain "MOVEQ #-1,d0; RTS;".
  2758.     Following that must be an initialized Resident structure with
  2759.     RTF_AUTOINIT set in rt_Flags, and an rt_Init pointer which points
  2760.     to four longwords.  These four longwords will be used in a call
  2761.     to MakeLibrary();
  2762.  
  2763.         - The size of your library/device base structure including initial
  2764.           Library or Device structure.
  2765.  
  2766.         - A pointer to a longword table of standard, then library
  2767.           specific function offsets, terminated with -1L.
  2768.           (short format offsets are also acceptable)
  2769.  
  2770.         - Pointer to data table in exec/InitStruct format for
  2771.           initialization of Library or Device structure.
  2772.  
  2773.         - Pointer to library initialization function, or NULL.
  2774.         Calling sequence:
  2775.             D0 = library base
  2776.             A0 = segList
  2777.             A6 = ExecBase
  2778.           This function must return in D0 the library/device base to be
  2779.           linked into the library/device list.  If the initialization
  2780.           function fails, the device memory must be manually deallocated,
  2781.           then NULL returned in D0.
  2782.  
  2783.    SEE ALSO
  2784.     exec/resident.i, FindResident
  2785.  
  2786. exec.library/InitSemaphore                         exec.library/InitSemaphore
  2787.  
  2788.    NAME
  2789.     InitSemaphore -- initialize a signal semaphore
  2790.  
  2791.    SYNOPSIS
  2792.     InitSemaphore(signalSemaphore)
  2793.               A0
  2794.  
  2795.     void InitSemaphore(struct SignalSemaphore *);
  2796.  
  2797.    FUNCTION
  2798.     This function initializes a signal semaphore and prepares it for
  2799.     use.  It does not allocate anything, but does initialize list
  2800.     pointers and the semaphore counters.
  2801.  
  2802.     Semaphores are often used to protect critical data structures
  2803.     or hardware that can only be accessed by one task at a time.
  2804.     After initialization, the address of the SignalSemaphore may be
  2805.     made available to any number of tasks.  Typically a task will
  2806.     try to ObtainSemaphore(), passing this address in.  If no other
  2807.     task owns the semaphore, then the call will lock and return
  2808.     quickly.  If more tasks try to ObtainSemaphore(), they will
  2809.     be put to sleep.  When the owner of the semaphore releases
  2810.     it, the next waiter in turn will be woken up.
  2811.  
  2812.     Semaphores are often preferable to the old-style Forbid()/Permit()
  2813.     type arbitration.  With Forbid()/Permit() *all* other tasks are
  2814.     prevented from running.  With semaphores, only those tasks that
  2815.     need access to whatever the semaphore protects are subject
  2816.     to waiting.
  2817.  
  2818.    INPUT
  2819.     signalSemaphore -- a signal semaphore structure (with all fields
  2820.                set to zero before the call)
  2821.  
  2822.    SEE ALSO
  2823.     ObtainSemaphore, ObtainSemaphoreShared, AttemptSemaphore,
  2824.     ReleaseSemaphore, Procure, Vacate, exec/semaphores.h
  2825.  
  2826. exec.library/InitStruct                               exec.library/InitStruct
  2827.  
  2828.    NAME
  2829.     InitStruct - initialize memory from a table
  2830.  
  2831.    SYNOPSIS
  2832.     InitStruct(initTable, memory, size);
  2833.            A1          A2      D0
  2834.  
  2835.     void InitStruct(struct InitStruct *, APTR, ULONG);
  2836.  
  2837.    FUNCTION
  2838.     Clear a memory area, then set up default values according to
  2839.     the data and offset values in the initTable.  Typically only assembly
  2840.     programs take advantage of this function, and only with the macros
  2841.     defined in "exec/initializers.i".
  2842.  
  2843.     The initialization table has byte commands to
  2844.  
  2845.          |a    ||byte|    |given||byte|          |once        |
  2846.     load |count||word| into |next ||rptr| offset, |repetitively |
  2847.             |long|
  2848.  
  2849.     Not all combinations are supported.  The offset, when specified, is
  2850.     relative to the memory pointer provided (Memory), and is initially
  2851.     zero.  The initialization data (InitTable) contains byte commands
  2852.     whose 8 bits are interpreted as follows:
  2853.  
  2854.     ddssnnnn
  2855.         dd    the destination type (and size):
  2856.         00  no offset, use next destination, nnnn is count
  2857.         01  no offset, use next destination, nnnn is repeat
  2858.         10  destination offset is in the next byte, nnnn is count
  2859.         11  destination offset is in the next 24-bits, nnnn is count
  2860.         ss    the size and location of the source:
  2861.         00  long, from the next two aligned words
  2862.         01  word, from the next aligned word
  2863.         10  byte, from the next byte
  2864.         11  ERROR - will cause an ALERT (see below)
  2865.       nnnn    the count or repeat:
  2866.          count  the (number+1) of source items to copy
  2867.         repeat  the source is copied (number+1) times.
  2868.  
  2869.     initTable commands are always read from the next even byte. Given
  2870.     destination offsets are always relative to the memory pointer (A2).
  2871.  
  2872.     The command %00000000 ends the InitTable stream: use %00010001 if you
  2873.     really want to copy one longword without a new offset.
  2874.  
  2875.     24 bit APTR not supported for 68020 compatibility -- use long.
  2876.  
  2877.    INPUTS
  2878.     initTable - the beginning of the commands and data to init
  2879.         Memory with.  Must be on an even boundary unless only
  2880.         byte initialization is done.  End table with "dc.b 0"
  2881.         or "dc.w 0".
  2882.     memory - the beginning of the memory to initialize.  Must be
  2883.         on an even boundary if size is specified.
  2884.     size - the size of memory, which is used to clear it before
  2885.         initializing it via the initTable.  If Size is zero,
  2886.         memory is not cleared before initializing.
  2887.  
  2888.         size must be an even number.
  2889.  
  2890.     SEE ALSO
  2891.     exec/initializers.i
  2892.  
  2893. exec.library/Insert                                       exec.library/Insert
  2894.  
  2895.    NAME
  2896.     Insert -- insert a node into a list
  2897.  
  2898.    SYNOPSIS
  2899.     Insert(list, node, listNode)
  2900.            A0    A1    A2
  2901.  
  2902.     void Insert(struct List *, struct Node *, struct Node *);
  2903.  
  2904.    FUNCTION
  2905.     Insert a node into a doubly linked list AFTER a given node
  2906.     position.  Insertion at the head of a list is possible by passing a
  2907.     zero value for listNode, though the AddHead function is slightly
  2908.     faster for that special case.
  2909.  
  2910.    WARNING
  2911.     This function does not arbitrate for access to the list.  The
  2912.     calling task must be the owner of the involved list.
  2913.  
  2914.    INPUTS
  2915.     list - a pointer to the target list header
  2916.     node - the node to insert
  2917.     listNode - the node after which to insert
  2918.  
  2919.     SEE ALSO
  2920.     AddHead, AddTail, Enqueue, RemHead, Remove, RemTail
  2921.  
  2922. exec.library/MakeFunctions                         exec.library/MakeFunctions
  2923.  
  2924.    NAME
  2925.     MakeFunctions -- construct a function jump table
  2926.  
  2927.    SYNOPSIS
  2928.     tableSize = MakeFunctions(target, functionArray, funcDispBase)
  2929.     D0              A0      A1         A2
  2930.  
  2931.     ULONG MakeFunctions(APTR,APTR,APTR);
  2932.  
  2933.    FUNCTION
  2934.     A low level function used by MakeLibrary to build jump tables of
  2935.     the type used by libraries, devices and resources.  It allows the
  2936.     table to be built anywhere in memory, and can be used both for
  2937.     initialization and replacement. This function also supports function
  2938.     pointer compression by expanding relative displacements into absolute
  2939.     pointers.
  2940.  
  2941.     The processor instruction cache is cleared after the table building.
  2942.  
  2943.    INPUT
  2944.     destination - the target address for the high memory end of the
  2945.         function jump table.  Typically this will be the library
  2946.         base pointer.
  2947.  
  2948.     functionArray - pointer to an array of function pointers or
  2949.         function displacements.  If funcDispBase is zero, the array
  2950.         is assumed to contain absolute pointers to functions. If
  2951.         funcDispBase is not zero, then the array is assumed to
  2952.         contain word displacements to functions.  In both cases,
  2953.         the array is terminated by a -1 (of the same size as the
  2954.         actual entry.
  2955.  
  2956.     funcDispBase - pointer to the base about which all function
  2957.         displacements are relative.  If zero, then the function
  2958.         array contains absolute pointers.
  2959.  
  2960.    RESULT
  2961.     tableSize - size of the new table in bytes (for LIB_NEGSIZE).
  2962.  
  2963.    SEE ALSO
  2964.     exec/MakeLibrary
  2965.  
  2966. exec.library/MakeLibrary                             exec.library/MakeLibrary
  2967.  
  2968.    NAME
  2969.     MakeLibrary -- construct a library
  2970.  
  2971.    SYNOPSIS
  2972.     library = MakeLibrary(vectors, structure, init, dSize, segList)
  2973.     D0              A0       A1      A2    D0     D1
  2974.  
  2975.     struct Library *MakeLibrary
  2976.                   (APTR,struct InitStruct *,APTR,ULONG,BPTR);
  2977.  
  2978.    FUNCTION
  2979.     This function is used for constructing a library vector and data
  2980.     area.  The same call is used to make devices.  Space for the library
  2981.     is allocated from the system's free memory pool.  The data portion of
  2982.     the library is initialized.  init may point to a library specific
  2983.     entry point.
  2984.  
  2985.    NOTE
  2986.     Starting with V36, the library base is longword adjusted.  The
  2987.     lib_PosSize and lib_NegSize fields of the library structure are
  2988.     adjusted to match.
  2989.  
  2990.    INPUTS
  2991.     vectors - pointer to an array of function pointers or function
  2992.         displacements.    If the first word of the array is -1, then
  2993.         the array contains relative word displacements (based off
  2994.         of vectors); otherwise, the array contains absolute
  2995.         function pointers. The vector list is terminated by a -1
  2996.         (of the same size as the pointers).
  2997.  
  2998.     structure - points to an "InitStruct" data region.  If NULL,
  2999.         then it will not be used.
  3000.  
  3001.     init -    If non-NULL, an entry point that will be called before adding
  3002.         the library to the system.  Registers are as follows:
  3003.             d0 = libAddr     ;Your Library Address
  3004.             a0 = segList    ;Your AmigaDOS segment list
  3005.             a6 = ExecBase    ;Address of exec.library
  3006.         The result of the init function must be the library address,
  3007.         or NULL for failure.   If NULL, the init point must manually
  3008.         deallocate the library base memory (based on the sizes stored
  3009.         in lib_PosSize and lib_NegSize).
  3010.  
  3011.     dSize - the size of the library data area, including the
  3012.         standard library node data.  This must be at leas
  3013.         sizeof(struct Library).
  3014.  
  3015.        segList - pointer to an AmigaDOS SegList (segment list).
  3016.          This is passed to a library's init code, and is used later
  3017.          for removing the library from memory.
  3018.  
  3019.    RESULT
  3020.     library - the reference address of the library.  This is the
  3021.           address used in references to the library, not the
  3022.           beginning of the memory area allocated.  If the library
  3023.           vector table require more system memory than is
  3024.           available, this function will return NULL.
  3025.  
  3026.    SEE ALSO
  3027.     InitStruct, InitResident, exec/initializers.i
  3028.  
  3029. exec.library/ObtainQuickVector                 exec.library/ObtainQuickVector
  3030.  
  3031.    NAME
  3032.     Function to obtain an install a Quick Interrupt vector            (V39)
  3033.  
  3034.    SYNOPSIS
  3035.     vector=ObtainQuickVector(interruptCode)
  3036.     d0                       a0
  3037.  
  3038.     ULONG ObtainQuickVector(APTR);
  3039.  
  3040.    FUNCTION
  3041.     This function will install the code pointer into the quick interrupt
  3042.     vector it allocates and returns to you the interrupt vector that
  3043.     your Quick Interrupt system needs to use.
  3044.  
  3045.     This function may also return 0 if no vectors are available.  Your
  3046.     hardware should be able to then fall back to using the shared
  3047.     interrupt server chain should this happen.
  3048.  
  3049.     The interrupt code is a direct connect to the physical interrupt.
  3050.     This means that it is the responsibility of your code to do all
  3051.     of the context saving/restoring required by interrupt code.
  3052.  
  3053.     Also, due to the performance of the interrupt controller, you may
  3054.     need to also watch for "false" interrupts.  These are interrupts
  3055.     that come in just after a DISABLE.  The reason this happens is
  3056.     because the interrupt may have been posted before the DISABLE
  3057.     hardware access is completed.  For example:
  3058.  
  3059.     myInt:        move.l    d0,-(sp)    ; Save d0...
  3060.             move.w    _intenar,d0    ; Get interrupt enable state
  3061.             btst.l    #INTB_INTEN,d0    ; Check if pending disable
  3062.             bne.s    realInt        ; If not, do real one...
  3063.     exitInt:    move.l    (sp)+,d0    ; Restore d0
  3064.             rte            ; Return from int...
  3065.     ;
  3066.     realInt:    ; Now do your int code...  d0 is already saved
  3067.             ; ALL other registers need to be saved if needed
  3068.             ; This includes a0/a1/d0/d1 as this is an interrupt
  3069.             ; and not a function call...
  3070.             ;
  3071.             bra.s    exitInt        ; Exit interrupt...
  3072.  
  3073.     If your interrupt will not play with system (OS) structures and your
  3074.     own structures are safe to play with you do not need to check for
  3075.     the disable.  It is only needed for when the system is in disable but
  3076.     that "one last interrupt" still got through.
  3077.  
  3078.    NOTE
  3079.     This function was not implemented fully until V39.  Due to a mis-cue
  3080.     it is not safe to call in V37 EXEC.  (Sorry)
  3081.  
  3082.    INPUTS
  3083.     A pointer to your interrupt code.  This code is not an EXEC interrupt
  3084.     but is dirrectly connected to the hardware interrupt.  Thus, the
  3085.     interrupt code must not modify any registers and must return via
  3086.     an RTE.
  3087.  
  3088.    RESULTS
  3089.     The 8-bit vector number used for Zorro-III Quick Interrupts
  3090.     If it returns 0, no quick interrupt was allocatable.  The device
  3091.     should at this point switch to using the shared interrupt server
  3092.     method.
  3093.  
  3094.    SEE ALSO
  3095.  
  3096. exec.library/ObtainSemaphore                     exec.library/ObtainSemaphore
  3097.  
  3098.    NAME
  3099.     ObtainSemaphore -- gain exclusive access to a semaphore
  3100.  
  3101.    SYNOPSIS
  3102.     ObtainSemaphore(signalSemaphore)
  3103.             A0
  3104.  
  3105.     void ObtainSemaphore(struct SignalSemaphore *);
  3106.  
  3107.    FUNCTION
  3108.     Signal semaphores are used to gain exclusive access to an object.
  3109.     ObtainSemaphore is the call used to gain this access.  If another
  3110.     user currently has the semaphore locked the call will block until
  3111.     the object is available.
  3112.  
  3113.     If the current task already has locked the semaphore and attempts to
  3114.     lock it again the call will still succeed.  A "nesting count" is
  3115.     incremented each time the current owning task of the semaphore calls
  3116.     ObtainSemaphore().  This counter is decremented each time
  3117.     ReleaseSemaphore() is called.  When the counter returns to zero the
  3118.     semaphore is actually released, and the next waiting task is called.
  3119.  
  3120.     A queue of waiting tasks is maintained on the stacks of the waiting
  3121.     tasks.    Each will be called in turn as soon as the current task
  3122.     releases the semaphore.
  3123.  
  3124.     Signal Semaphores are different than Procure()/Vacate() semaphores.
  3125.     The former requires less CPU time, especially if the semaphore is
  3126.     not currently locked.  They require very little set up and user
  3127.     thought.  The latter flavor of semaphore make no assumptions about
  3128.     how they are used -- they are completely general.  Unfortunately
  3129.     they are not as efficient as signal semaphores, and require the
  3130.     locker to have done some setup before doing the call.
  3131.  
  3132.    INPUT
  3133.        signalSemaphore -- an initialized signal semaphore structure
  3134.  
  3135.    NOTE
  3136.     This function preserves all registers (see BUGS).
  3137.  
  3138.    BUGS
  3139.     Until V37, this function could destroy A0.
  3140.  
  3141.    SEE ALSO
  3142.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  3143.     AttemptSemaphore(), ObtainSemaphoreList(), Procure(), Vacate()
  3144.  
  3145. exec.library/ObtainSemaphoreList             exec.library/ObtainSemaphoreList
  3146.  
  3147.    NAME
  3148.     ObtainSemaphoreList -- get a list of semaphores.
  3149.  
  3150.    SYNOPSIS
  3151.     ObtainSemaphoreList(list)
  3152.                 A0
  3153.  
  3154.     void ObtainSemaphoreList(struct List *);
  3155.  
  3156.    FUNCTION
  3157.     Signal semaphores may be linked together into a list. This function
  3158.     takes a list of these semaphores and attempts to lock all of them at
  3159.     once. This call is preferable to applying ObtainSemaphore() to each
  3160.     element in the list because it attempts to lock all the elements
  3161.     simultaneously, and won't deadlock if someone is attempting to lock
  3162.     in some other order.
  3163.  
  3164.     This function assumes that only one task at a time will attempt to
  3165.     lock the entire list of semaphores.  In other words, there needs to
  3166.     be a higher level lock (perhaps another signal semaphore...) that is
  3167.     used before someone attempts to lock the semaphore list via
  3168.     ObtainSemaphoreList().
  3169.  
  3170.     Note that deadlocks may result if this call is used AND someone
  3171.     attempts to use ObtainSemaphore() to lock more than one semaphore on
  3172.     the list.  If you wish to lock more than semaphore (but not all of
  3173.     them) then you should obtain the higher level lock (see above)
  3174.  
  3175.    INPUT
  3176.        list -- a list of signal semaphores
  3177.  
  3178.    SEE ALSO
  3179.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  3180.     AttemptSemaphore(), ObtainSemaphoreShared(), Procure(), Vacate()
  3181.  
  3182. exec.library/ObtainSemaphoreShared         exec.library/ObtainSemaphoreShared
  3183.  
  3184.     NAME
  3185.     ObtainSemaphoreShared -- gain shared access to a semaphore (V36)
  3186.  
  3187.     SYNOPSIS
  3188.     ObtainSemaphoreShared(signalSemaphore)
  3189.                           a0
  3190.  
  3191.     void ObtainSemaphoreShared(struct SignalSemaphore *);
  3192.  
  3193.     FUNCTION
  3194.     A lock on a signal semaphore may either be exclusive, or shared.
  3195.     Exclusive locks are granted by the ObtainSemaphore() and
  3196.     AttemptSemaphore() functions.  Shared locks are granted by
  3197.     ObtainSemaphoreShared().  Calls may be nested.
  3198.  
  3199.     Any number of tasks may simultaneously hold a shared lock on a
  3200.     semaphore.  Only one task may hold an exclusive lock.  A typical
  3201.     application is a list that is often read, but only occasionally
  3202.     written to.
  3203.  
  3204.     Any exlusive locker will be held off until all shared lockers
  3205.     release the semaphore.  Likewise, if an exlusive lock is held,
  3206.     all potential shared lockers will block until the exclusive lock
  3207.     is released.  All shared lockers are restarted at the same time.
  3208.  
  3209.     EXAMPLE
  3210.         ObtainSemaphoreShared(ss);
  3211.         /* read data */
  3212.         ReleaseSemaohore(ss);
  3213.  
  3214.         ObtainSemaphore(ss);
  3215.         /* modify data */
  3216.         ReleaseSemaohore(ss);
  3217.  
  3218.     NOTES
  3219.     While this function was added for V36, the feature magically works
  3220.     with all older semaphore structures.
  3221.  
  3222.     A task owning a shared lock must not attempt to get an exclusive
  3223.     lock on the same semaphore.
  3224.  
  3225.     Starting in V39, if the caller already has an exclusive lock on the
  3226.     semaphore it will return with another nesting of the lock.  Pre-V39
  3227.     this would cause a deadlock.  For pre-V39 use, you can use the
  3228.     following workaround:
  3229.  
  3230.         /* Try to get the shared semaphore */
  3231.         if (!AttemptSemaphoreShared(ss))
  3232.         {
  3233.             /* Check if we can get the exclusive version */
  3234.             if (!AttemptSemaphore(ss))
  3235.             {
  3236.                 /* Oh well, wait for the shared lock */
  3237.                 ObtainSemaphoreShared(ss));
  3238.             }
  3239.         }
  3240.         :
  3241.         :
  3242.         ReleaseSemaphore(ss);
  3243.  
  3244.     INPUT
  3245.     signalSemaphore -- an initialized signal semaphore structure
  3246.  
  3247.     NOTE
  3248.     This call is guaranteed to preserve all registers, starting with
  3249.     V37 exec.
  3250.  
  3251.     RESULT
  3252.  
  3253.     SEE ALSO
  3254.     ObtainSemaphore(), InitSemaphore(), ReleaseSemaphore(),
  3255.     AttemptSemaphore(), ObtainSemaphoreList(), Procure(), Vacate()
  3256.  
  3257. exec.library/OldOpenLibrary                       exec.library/OldOpenLibrary
  3258.  
  3259.    NAME
  3260.     OldOpenLibrary -- obsolete OpenLibrary
  3261.  
  3262.    SYNOPSIS
  3263.     library = OldOpenLibrary(libName)
  3264.     D0             A1
  3265.  
  3266.     struct Library *OldOpenLibrary(APTR);
  3267.  
  3268.    FUNCTION
  3269.     The 1.0 release of the Amiga system had an incorrect version of
  3270.     OpenLibrary that did not check the version number during the
  3271.     library open.  This obsolete function is provided so that object
  3272.     code compiled using a 1.0 system will still run.
  3273.  
  3274.     This exactly the same as "OpenLibrary(libName,0L);"
  3275.  
  3276.    INPUTS
  3277.     libName - the name of the library to open
  3278.  
  3279.    RESULTS
  3280.     library - a library pointer for a successful open, else zero
  3281.  
  3282.    SEE ALSO
  3283.     CloseLibrary
  3284.  
  3285. exec.library/OpenDevice                               exec.library/OpenDevice
  3286.  
  3287.    NAME
  3288.     OpenDevice -- gain access to a device
  3289.  
  3290.    SYNOPSIS
  3291.     error = OpenDevice(devName, unitNumber, iORequest, flags)
  3292.     D0           A0        D0        A1       D1
  3293.  
  3294.     BYTE OpenDevice(STRPTR,ULONG,struct IORequest *,ULONG);
  3295.  
  3296.    FUNCTION
  3297.     This function opens the named device/unit and initializes the given
  3298.     I/O request block.  Specific documentation on opening procedures
  3299.     may come with certain devices.
  3300.  
  3301.     The device may exist in memory, or on disk; this is transparent to
  3302.     the OpenDevice caller.
  3303.  
  3304.     A full path name for the device name is legitimate.  For example
  3305.     "test:devs/fred.device".  This allows the use of custom devices
  3306.     without requiring the user to copy the device into the system's
  3307.     DEVS: directory.
  3308.  
  3309.    NOTES
  3310.     All calls to OpenDevice should have matching calls to CloseDevice!
  3311.  
  3312.     Devices on disk cannot be opened until after DOS has been
  3313.     started.
  3314.  
  3315.     As of V36 tasks can safely call OpenDevice, though DOS may open
  3316.     system requesters (e.g., asking the user to insert the Workbench
  3317.     disk if DEVS: is not online).  You must call this function from a
  3318.     DOS Process if you want to turn off DOS requesters.
  3319.  
  3320.    INPUTS
  3321.     devName - requested device name
  3322.  
  3323.     unitNumber - the unit number to open on that device.  The format of
  3324.         the unit number is device specific.  If the device does
  3325.         not have separate units, send a zero.
  3326.  
  3327.     iORequest - the I/O request block to be returned with
  3328.         appropriate fields initialized.
  3329.  
  3330.     flags - additional driver specific information.  This is sometimes
  3331.         used to request opening a device with exclusive access.
  3332.  
  3333.    RESULTS
  3334.     error - Returns a sign-extended copy of the io_Error field
  3335.         of the IORequest.  Zero if successful, else an error code
  3336.         is returned.
  3337.  
  3338.    BUGS
  3339.     AmigaDOS file names are not case sensitive, but Exec lists are.  If
  3340.     the library name is specified in a different case than it exists on
  3341.     disk, unexpected results may occur.
  3342.  
  3343.     Prior to V36, tasks could not make OpenDevice calls requiring disk
  3344.     access (since tasks are not allowed to make dos.library calls).
  3345.     Now OpenDevice is protected from tasks.
  3346.  
  3347.    SEE ALSO
  3348.     CloseDevice, DoIO, SendIO, CheckIO, AbortIO, WaitIO
  3349.  
  3350. exec.library/OpenLibrary                             exec.library/OpenLibrary
  3351.  
  3352.    NAME
  3353.     OpenLibrary -- gain access to a library
  3354.  
  3355.    SYNOPSIS
  3356.     library = OpenLibrary(libName, version)
  3357.     D0              A1       D0
  3358.  
  3359.     struct Library *OpenLibrary(STRPTR, ULONG);
  3360.  
  3361.    FUNCTION
  3362.     This function returns a pointer to a library that was previously
  3363.     installed into the system.  If the requested library is exists, and
  3364.     if the library version is greater than or equal to the requested
  3365.     version, then the open will succeed.
  3366.  
  3367.     The library may exist in memory, or on disk; this is transparent to
  3368.     the OpenLibrary caller.  Only Processes are allowed to call
  3369.     OpenLibrary (since OpenLibrary may in turn call dos.library).
  3370.  
  3371.     A full path name for the library name is legitimate.  For example
  3372.     "wp:libs/wp.library".  This allows the use of custom libraries
  3373.     without requiring the user to copy the library into the system's
  3374.     LIBS: directory.
  3375.  
  3376.    NOTES
  3377.     All calls to OpenLibrary should have matching calls to CloseLibrary!
  3378.  
  3379.     Libraries on disk cannot be opened until after DOS has been
  3380.     started.
  3381.  
  3382.     As of V36 tasks can safely call OpenLibrary, though DOS may open
  3383.     system requesters (e.g., asking the user to insert the Workbench
  3384.     disk if LIBS: is not online).  You must call this function from a
  3385.     DOS Process if you want to turn off DOS requesters.
  3386.  
  3387.    INPUTS
  3388.     libName - the name of the library to open
  3389.  
  3390.     version - the version of the library required.
  3391.  
  3392.    RESULTS
  3393.     library - a library pointer for a successful open, else zero
  3394.  
  3395.    BUGS
  3396.     AmigaDOS file names are not case sensitive, but Exec lists are. If
  3397.     the library name is specified in a different case than it exists on
  3398.     disk, unexpected results may occur.
  3399.  
  3400.     Prior to V36, tasks could not make OpenLibrary calls requiring disk
  3401.     access (since tasks are not allowed to make dos.library calls).
  3402.     Now OpenLibrary is protected from tasks.
  3403.  
  3404.     The version number of the resident tag in disk based library must
  3405.     match the version number of the library, or V36 may fail to load it.
  3406.  
  3407.    SEE ALSO
  3408.     CloseLibrary
  3409.  
  3410. exec.library/OpenResource                           exec.library/OpenResource
  3411.  
  3412.    NAME
  3413.     OpenResource -- gain access to a resource
  3414.  
  3415.    SYNOPSIS
  3416.     resource = OpenResource(resName)
  3417.     D0            A1
  3418.  
  3419.     APTR OpenResource(STRPTR);
  3420.  
  3421.    FUNCTION
  3422.     This function returns a pointer to a resource that was previously
  3423.     installed into the system.
  3424.  
  3425.     There is no CloseResource() function.
  3426.  
  3427.    INPUTS
  3428.        resName - the name of the resource requested.
  3429.  
  3430.    RESULTS
  3431.     resource - if successful, a resource pointer, else NULL
  3432.  
  3433. exec.library/Permit                                       exec.library/Permit
  3434.  
  3435.     NAME
  3436.     Permit -- permit task rescheduling.
  3437.  
  3438.     SYNOPSIS
  3439.     Permit()
  3440.  
  3441.     void Permit(void);
  3442.  
  3443.     FUNCTION
  3444.     Allow other tasks to be scheduled to run by the dispatcher, after a
  3445.     matching Forbid() has been executed.
  3446.  
  3447.     RESULTS
  3448.     Other tasks will be rescheduled as they are ready to run. In order
  3449.     to restore normal task rescheduling, the programmer must execute
  3450.     exactly one call to Permit() for every call to Forbid().
  3451.  
  3452.     NOTE
  3453.     This call is guaranteed to preserve all registers.
  3454.  
  3455.     SEE ALSO
  3456.     Forbid, Disable, Enable
  3457.  
  3458. exec.library/Procure                                     exec.library/Procure
  3459.  
  3460.    NAME
  3461.     Procure -- bid for a semaphore                                   (V39)
  3462.  
  3463.    SYNOPSIS
  3464.     Procure(semaphore, bidMessage)
  3465.         A0        A1
  3466.  
  3467.     VOID Procure(struct SignalSemaphore *, struct SemaphoreMessage *);
  3468.  
  3469.    FUNCTION
  3470.     This function is used to obtain a semaphore in an async manner.
  3471.     Like ObtainSemaphore(), it will obtain a SignalSemaphore for you
  3472.     but unlike ObtainSemaphore(), you will not block until you get
  3473.     the semaphore.  Procure() will just post a request for the semaphore
  3474.     and will return.  When the semaphore is available (which could
  3475.     be at any time) the bidMessage will ReplyMsg() and you will own
  3476.     the semaphore.  This lets you wait on multiple semaphores at once
  3477.     and to continue processing while waiting for the semaphore.
  3478.  
  3479.     NOTE:  Pre-V39, Procure() and Vacate() did not work correctly.
  3480.     They also did not operate on SignalSemaphore semaphores.
  3481.     Old (and broken) MessageSemaphore use as of V39 will no longer work.
  3482.  
  3483.    INPUT
  3484.     semaphore - The SignalSemaphore that you wish to Procure()
  3485.     bidMessage- The SemaphoreMessage that you wish replied when
  3486.         you obtain access to the semaphore.  The message's
  3487.         ssm_Semaphore field will point at the semaphore that
  3488.         was obtained.  If the ssm_Semaphore field is NULL,
  3489.         the Procure() was aborted via Vacate().
  3490.         The mn_ReplyPort field of the message must point to
  3491.         a valid message port.
  3492.         To obtain a shared semaphore, the ln_Name field
  3493.         must be set to 1.  For an exclusive lock, the ln_Name
  3494.         field must be 0.  No other values are valid.
  3495.  
  3496.    BUGS
  3497.     Before V39, Procure() and Vacate() used a different semaphore
  3498.     system that was very broken.  This new system is only available
  3499.     as of V39 even though the LVOs are the same.
  3500.  
  3501.    SEE ALSO
  3502.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  3503.     AttemptSemaphore(), ObtainSemaphoreList(), Vacate(), ObtainSemaphore()
  3504.  
  3505. exec.library/PutMsg                                       exec.library/PutMsg
  3506.  
  3507.    NAME
  3508.     PutMsg -- put a message to a message port
  3509.  
  3510.    SYNOPSIS
  3511.     PutMsg(port, message)
  3512.            A0    A1
  3513.  
  3514.     void PutMsg(struct MsgPort *, struct Message *);
  3515.  
  3516.    FUNCTION
  3517.     This function attaches a message to the end of a given message port.
  3518.     It provides a fast, non-copying message sending mechanism.
  3519.  
  3520.     Messages can be attached to only one port at a time.  The message
  3521.     body can be of any size or form.  Because messages are not copied,
  3522.     cooperating tasks share the same message memory.  The sender task
  3523.     must not recycle the message until it has been replied by the
  3524.     receiver.  Of course this depends on the message handling conventions
  3525.     setup by the involved tasks.  If the ReplyPort field is non-zero,
  3526.     when the message is replied by the receiver, it will be sent back to
  3527.     that port.
  3528.  
  3529.     Any one of the following actions can be set to occur when a message
  3530.     is put:
  3531.  
  3532.         1. no special action
  3533.         2. signal a given task (specified by MP_SIGTASK)
  3534.         3. cause a software interrupt (specified by MP_SIGTASK)
  3535.  
  3536.     The action is selected depending on the value found in the MP_FLAGS
  3537.     of the destination port.
  3538.  
  3539.    IMPLEMENTATION
  3540.     1.  Sets the LN_TYPE field to "NT_MESSAGE".
  3541.     2.  Attaches the message to the destination port.
  3542.     3.  Performs the specified arrival action at the destination.
  3543.  
  3544.    INPUT
  3545.     port - pointer to a message port
  3546.     message - pointer to a message
  3547.  
  3548.    SEE ALSO
  3549.     GetMsg, ReplyMsg, exec/ports.h
  3550.  
  3551. exec.library/RawDoFmt                                   exec.library/RawDoFmt
  3552.  
  3553.    NAME
  3554.     RawDoFmt -- format data into a character stream.
  3555.  
  3556.    SYNOPSIS
  3557.     NextData = RawDoFmt(FormatString, DataStream, PutChProc, PutChData);
  3558.        d0                  a0            a1          a2         a3
  3559.  
  3560.     APTR RawDoFmt(STRPTR,APTR,void (*)(),APTR);
  3561.  
  3562.    FUNCTION
  3563.     perform "C"-language-like formatting of a data stream, outputting
  3564.     the result a character at a time.  Where % formatting commands are
  3565.     found in the FormatString, they will be replaced with the
  3566.     corresponding element in the DataStream.  %% must be used in the
  3567.     string if a % is desired in the output.
  3568.  
  3569.     Under V36, RawDoFmt() returns a pointer to the end of the DataStream
  3570.     (The next argument that would have been processed).  This allows
  3571.     multiple formatting passes to be made using the same data.
  3572.  
  3573.    INPUTS
  3574.     FormatString - a "C"-language-like NULL terminated format string,
  3575.     with the following supported % options:
  3576.  
  3577.      %[flags][width.limit][length]type
  3578.  
  3579.     flags  - only one allowed. '-' specifies left justification.
  3580.     width  - field width.  If the first character is a '0', the
  3581.          field will be padded with leading 0's.
  3582.       .    - must follow the field width, if specified
  3583.     limit  - maximum number of characters to output from a string.
  3584.          (only valid for %s).
  3585.     length - size of input data defaults to WORD for types d, x,
  3586.          and c, 'l' changes this to long (32-bit).
  3587.     type   - supported types are:
  3588.             b - BSTR, data is 32-bit BPTR to byte count followed
  3589.                 by a byte string, or NULL terminated byte string.
  3590.                 A NULL BPTR is treated as an empty string.
  3591.                 (Added in V36 exec)
  3592.             d - decimal
  3593.             u - unsigned decimal (Added in V37 exec)
  3594.             x - hexadecimal
  3595.             s - string, a 32-bit pointer to a NULL terminated
  3596.                 byte string.  In V36, a NULL pointer is treated
  3597.                 as an empty string
  3598.             c - character
  3599.  
  3600.     DataStream - a stream of data that is interpreted according to
  3601.          the format string.  Often this is a pointer into
  3602.          the task's stack.
  3603.     PutChProc  - the procedure to call with each character to be
  3604.          output, called as:
  3605.  
  3606.     PutChProc(Char,  PutChData);
  3607.           D0-0:8 A3
  3608.  
  3609.         the procedure is called with a NULL Char at the end of
  3610.         the format string.
  3611.  
  3612.     PutChData - a value that is passed through to the PutChProc
  3613.         procedure.  This is untouched by RawDoFmt, and may be
  3614.         modified by the PutChProc.
  3615.  
  3616.    EXAMPLE
  3617.     ;
  3618.     ; Simple version of the C "sprintf" function.  Assumes C-style
  3619.     ; stack-based function conventions.
  3620.     ;
  3621.     ;   long eyecount;
  3622.     ;   eyecount=2;
  3623.     ;   sprintf(string,"%s have %ld eyes.","Fish",eyecount);
  3624.     ;
  3625.     ; would produce "Fish have 2 eyes." in the string buffer.
  3626.     ;
  3627.         XDEF _sprintf
  3628.         XREF _AbsExecBase
  3629.         XREF _LVORawDoFmt
  3630.     _sprintf:    ; ( ostring, format, {values} )
  3631.         movem.l a2/a3/a6,-(sp)
  3632.  
  3633.         move.l    4*4(sp),a3       ;Get the output string pointer
  3634.         move.l    5*4(sp),a0       ;Get the FormatString pointer
  3635.         lea.l    6*4(sp),a1       ;Get the pointer to the DataStream
  3636.         lea.l    stuffChar(pc),a2
  3637.         move.l    _AbsExecBase,a6
  3638.         jsr    _LVORawDoFmt(a6)
  3639.  
  3640.         movem.l (sp)+,a2/a3/a6
  3641.         rts
  3642.  
  3643.     ;------ PutChProc function used by RawDoFmt -----------
  3644.     stuffChar:
  3645.         move.b    d0,(a3)+        ;Put data to output string
  3646.         rts
  3647.  
  3648.    WARNING
  3649.     This Amiga ROM function formats word values in the data stream.  If
  3650.     your compiler defaults to longs, you must add an "l" to your
  3651.     % specifications.  This can get strange for characters, which might
  3652.     look like "%lc".
  3653.  
  3654.     The result of RawDoFmt() is *ONLY* valid in V36 and later releases
  3655.     of EXEC.  Pre-V36 versions of EXEC have "random" return values.
  3656.  
  3657.    SEE ALSO
  3658.     Documentation on the C language "printf" call in any C language
  3659.     reference book.
  3660.  
  3661. exec.library/ReleaseSemaphore                   exec.library/ReleaseSemaphore
  3662.  
  3663.    NAME
  3664.     ReleaseSemaphore -- make signal semaphore available to others
  3665.  
  3666.    SYNOPSIS
  3667.     ReleaseSemaphore(signalSemaphore)
  3668.              A0
  3669.  
  3670.     void ReleaseSemaphore(struct SignalSemaphore *);
  3671.  
  3672.    FUNCTION
  3673.     ReleaseSemaphore() is the inverse of ObtainSemaphore(). It makes
  3674.     the semaphore lockable to other users.    If tasks are waiting for
  3675.     the semaphore and this this task is done with the semaphore then
  3676.     the next waiting task is signalled.
  3677.  
  3678.     Each ObtainSemaphore() call must be balanced by exactly one
  3679.     ReleaseSemaphore() call.  This is because there is a nesting count
  3680.     maintained in the semaphore of the number of times that the current
  3681.     task has locked the semaphore. The semaphore is not released to
  3682.     other tasks until the number of releases matches the number of
  3683.     obtains.
  3684.  
  3685.     Needless to say, havoc breaks out if the task releases more times
  3686.     than it has obtained.
  3687.  
  3688.    INPUT
  3689.        signalSemaphore -- an initialized signal semaphore structure
  3690.  
  3691.    NOTE
  3692.     This call is guaranteed to preserve all registers.
  3693.  
  3694.    SEE ALSO
  3695.     InitSemaphore(), ObtainSemaphore(), ObtainSemaphoreShared()
  3696.  
  3697. exec.library/ReleaseSemaphoreList           exec.library/ReleaseSemaphoreList
  3698.  
  3699.    NAME
  3700.     ReleaseSemaphoreList -- make a list of semaphores available
  3701.  
  3702.    SYNOPSIS
  3703.     ReleaseSemaphoreList(list)
  3704.                  A0
  3705.  
  3706.     void ReleaseSemaphoreList(struct List *);
  3707.  
  3708.    FUNCTION
  3709.     ReleaseSemaphoreList() is the inverse of ObtainSemaphoreList(). It
  3710.     releases each element in the semaphore list.
  3711.  
  3712.     Needless to say, havoc breaks out if the task releases more times
  3713.     than it has obtained.
  3714.  
  3715.    INPUT
  3716.        list -- a list of signal semaphores
  3717.  
  3718.    SEE ALSO
  3719.     ObtainSemaphoreList()
  3720.  
  3721. exec.library/RemDevice                                 exec.library/RemDevice
  3722.  
  3723.    NAME
  3724.     RemDevice -- remove a device from the system
  3725.  
  3726.    SYNOPSIS
  3727.     RemDevice(device)
  3728.               A1
  3729.  
  3730.     void RemDevice(struct Device *);
  3731.  
  3732.    FUNCTION
  3733.     This function calls the device's EXPUNGE vector, which requests
  3734.     that a device delete itself.  The device may refuse to do this if
  3735.     it is busy or currently open. This is not typically called by user
  3736.     code.
  3737.  
  3738.     There are certain, limited circumstances where it may be
  3739.     appropriate to attempt to specifically flush a certain device.
  3740.     Example:
  3741.  
  3742.      /* Attempts to flush the named device out of memory. */
  3743.      #include <exec/types.h>
  3744.      #include <exec/execbase.h>
  3745.  
  3746.      void FlushDevice(name)
  3747.      STRPTR name;
  3748.      {
  3749.      struct Device *result;
  3750.  
  3751.         Forbid();
  3752.         if(result=(struct Device *)FindName(&SysBase->DeviceList,name))
  3753.         RemDevice(result);
  3754.         Permit();
  3755.      }
  3756.  
  3757.    INPUTS
  3758.     device - pointer to a device node
  3759.  
  3760.    SEE ALSO
  3761.     AddLibrary
  3762.  
  3763. exec.library/RemHead                                     exec.library/RemHead
  3764.  
  3765.    NAME
  3766.     RemHead -- remove the head node from a list
  3767.  
  3768.    SYNOPSIS
  3769.     node = RemHead(list)
  3770.     D0           A0
  3771.  
  3772.     struct Node *RemHead(struct List *);
  3773.  
  3774.    FUNCTION
  3775.     Get a pointer to the head node and remove it from the list.
  3776.     Assembly programmers may prefer to use the REMHEAD macro from
  3777.     "exec/lists.i".
  3778.  
  3779.    WARNING
  3780.     This function does not arbitrate for access to the list.  The
  3781.     calling task must be the owner of the involved list.
  3782.  
  3783.    INPUTS
  3784.     list - a pointer to the target list header
  3785.  
  3786.    RESULT
  3787.     node - the node removed or zero when empty list
  3788.  
  3789.    SEE ALSO
  3790.     AddHead, AddTail, Enqueue, Insert, Remove, RemTail
  3791.  
  3792. exec.library/RemIntServer                           exec.library/RemIntServer
  3793.  
  3794.    NAME
  3795.     RemIntServer -- remove an interrupt server from a server chain
  3796.  
  3797.    SYNOPSIS
  3798.     RemIntServer(intNum, interrupt)
  3799.              D0      A1
  3800.  
  3801.     void RemIntServer(ULONG,struct Interrupt *);
  3802.  
  3803.    FUNCTION
  3804.     This function removes an interrupt server node from the given
  3805.     server chain.
  3806.  
  3807.     If this server was the last one on this chain, interrupts for this
  3808.     chain are disabled.
  3809.  
  3810.    INPUTS
  3811.     intNum - the Paula interrupt bit (0..14)
  3812.     interrupt - pointer to an interrupt server node
  3813.  
  3814.    BUGS
  3815.     Before V36 Kickstart, the feature that disables the interrupt
  3816.     would not function.  For most server chains this does not
  3817.     cause a problem.
  3818.  
  3819.    SEE ALSO
  3820.     AddIntServer, hardware/intbits.h
  3821.  
  3822. exec.library/RemLibrary                               exec.library/RemLibrary
  3823.  
  3824.    NAME
  3825.     RemLibrary -- remove a library from the system
  3826.  
  3827.    SYNOPSIS
  3828.     RemLibrary(library)
  3829.                A1
  3830.  
  3831.     void RemLibrary(struct Library *);
  3832.  
  3833.    FUNCTION
  3834.     This function calls the library's EXPUNGE vector, which requests
  3835.     that a library delete itself.  The library may refuse to do this if
  3836.     it is busy or currently open. This is not typically called by user
  3837.     code.
  3838.  
  3839.     There are certain, limited circumstances where it may be
  3840.     appropriate to attempt to specifically flush a certain Library.
  3841.     Example:
  3842.  
  3843.      /* Attempts to flush the named library out of memory. */
  3844.      #include <exec/types.h>
  3845.      #include <exec/execbase.h>
  3846.  
  3847.      void FlushLibrary(name)
  3848.      STRPTR name;
  3849.      {
  3850.      struct Library *result;
  3851.  
  3852.         Forbid();
  3853.         if(result=(struct Library *)FindName(&SysBase->LibList,name))
  3854.         RemLibrary(result);
  3855.         Permit();
  3856.      }
  3857.  
  3858.    INPUTS
  3859.     library - pointer to a library node structure
  3860.  
  3861. exec.library/RemMemHandler                         exec.library/RemMemHandler
  3862.  
  3863.    NAME
  3864.     RemMemHandler - Remove low memory handler from exec              (V39)
  3865.  
  3866.    SYNOPSIS
  3867.     RemMemHandler(memHandler)
  3868.                   A1
  3869.  
  3870.     VOID RemMemHandler(struct Interrupt *);
  3871.  
  3872.    FUNCTION
  3873.     This function removes the low memory handler from the system.
  3874.     This function can be called from within a handler.  If removing
  3875.     oneself, it is important that the handler returns MEM_ALL_DONE.
  3876.  
  3877.    NOTE
  3878.     When removing a handler, the handler may be called until this
  3879.     function returns.  Thus, the handler must still be valid until
  3880.     then.
  3881.  
  3882.    INPUTS
  3883.     memHandler - Pointer to a handler added with AddMemHandler()
  3884.  
  3885.    SEE ALSO
  3886.     AddMemHandler, exec/interrupts.i
  3887.  
  3888. exec.library/Remove                                       exec.library/Remove
  3889.  
  3890.    NAME
  3891.     Remove -- remove a node from a list
  3892.  
  3893.    SYNOPSIS
  3894.     Remove(node)
  3895.            A1
  3896.  
  3897.     void Remove(struct Node *);
  3898.  
  3899.    FUNCTION
  3900.     Unlink a node from whatever list it is in.  Nodes that are not part
  3901.     of a list must not be passed to this function!  Assembly programmers
  3902.     may prefer to use the REMOVE macro from "exec/lists.i".
  3903.  
  3904.    WARNING
  3905.     This function does not arbitrate for access to the list.  The
  3906.     calling task must be the owner of the involved list.
  3907.  
  3908.    INPUTS
  3909.     node - the node to remove
  3910.  
  3911.    SEE ALSO
  3912.     AddHead, AddTail, Enqueue, Insert, RemHead, RemTail
  3913.  
  3914. exec.library/RemPort                                     exec.library/RemPort
  3915.  
  3916.    NAME
  3917.     RemPort -- remove a message port from the system
  3918.  
  3919.    SYNOPSIS
  3920.     RemPort(port)
  3921.         A1
  3922.  
  3923.     void RemPort(struct MsgPort *);
  3924.  
  3925.    FUNCTION
  3926.     This function removes a message port structure from the system's
  3927.     message port list.  Subsequent attempts to rendezvous by name with
  3928.     this port will fail.
  3929.  
  3930.    INPUTS
  3931.     port - pointer to a message port
  3932.  
  3933.    SEE ALSO
  3934.     AddPort, FindPort
  3935.  
  3936. exec.library/RemResource                             exec.library/RemResource
  3937.  
  3938.    NAME
  3939.     RemResource -- remove a resource from the system
  3940.  
  3941.    SYNOPSIS
  3942.     RemResource(resource)
  3943.            A1
  3944.  
  3945.     void RemResource(APTR);
  3946.  
  3947.    FUNCTION
  3948.     This function removes an existing resource from the system resource
  3949.     list.  There must be no outstanding users of the resource.
  3950.  
  3951.    INPUTS
  3952.     resource - pointer to a resource node
  3953.  
  3954.    SEE ALSO
  3955.     AddResource
  3956.  
  3957. exec.library/RemSemaphore                           exec.library/RemSemaphore
  3958.  
  3959.    NAME
  3960.     RemSemaphore -- remove a signal semaphore from the system
  3961.  
  3962.    SYNOPSIS
  3963.     RemSemaphore(signalSemaphore)
  3964.              A1
  3965.  
  3966.     void RemSemaphore(struct SignalSemaphore *);
  3967.  
  3968.    FUNCTION
  3969.     This function removes a signal semaphore structure from the
  3970.     system's signal semaphore list.  Subsequent attempts to
  3971.     rendezvous by name with this semaphore will fail.
  3972.  
  3973.    INPUTS
  3974.        signalSemaphore -- an initialized signal semaphore structure
  3975.  
  3976.    SEE ALSO
  3977.     AddSemaphore, FindSemaphore
  3978.  
  3979.  
  3980. exec.library/RemTail                                     exec.library/RemTail
  3981.  
  3982.    NAME
  3983.     RemTail -- remove the tail node from a list
  3984.  
  3985.    SYNOPSIS
  3986.     node = RemTail(list)
  3987.     D0           A0
  3988.  
  3989.     struct Node *RemTail(struct List *);
  3990.  
  3991.    FUNCTION
  3992.     Remove the last node from a list, and return a pointer to it. If
  3993.     the list is empty, return zero. Assembly programmers may prefer to
  3994.     use the REMTAIL macro from "exec/lists.i".
  3995.  
  3996.    WARNING
  3997.     This function does not arbitrate for access to the list.  The
  3998.     calling task must be the owner of the involved list.
  3999.  
  4000.    INPUTS
  4001.     list - a pointer to the target list header
  4002.  
  4003.    RESULT
  4004.     node - the node removed or zero when empty list
  4005.  
  4006.    SEE ALSO
  4007.     AddHead, AddTail, Enqueue, Insert, Remove, RemHead, RemTail
  4008.  
  4009. exec.library/RemTask                                     exec.library/RemTask
  4010.  
  4011.    NAME
  4012.     RemTask -- remove a task from the system
  4013.  
  4014.    SYNOPSIS
  4015.     RemTask(task)
  4016.         A1
  4017.  
  4018.     void RemTask(struct Task *);
  4019.  
  4020.    FUNCTION
  4021.     This function removes a task from the system.  Deallocation of
  4022.     resources should have been performed prior to calling this
  4023.     function.  Removing some other task is very dangerous.    Generally
  4024.     is is best to arrange for tasks to call RemTask(0L) on themselves.
  4025.  
  4026.     RemTask will automagically free any memory lists attached to the
  4027.     task's TC_MEMENTRY list.
  4028.  
  4029.    INPUTS
  4030.     task - pointer to the task node representing the task to be
  4031.            removed.  A zero value indicates self removal, and will
  4032.            cause the next ready task to begin execution.
  4033.  
  4034.    BUGS
  4035.     Before V36 if RemTask() was called on a task other than the current
  4036.     task, and that task was created with amiga.lib/CreateTask, there was
  4037.     a slight chance of a crash.  The problem can be hidden by bracketing
  4038.     RemTask() with Forbid()/Permit().
  4039.  
  4040.    SEE ALSO
  4041.     AddTask, exec/AllocEntry, amiga.lib/DeleteTask
  4042.  
  4043. exec.library/ReplyMsg                                   exec.library/ReplyMsg
  4044.  
  4045.    NAME
  4046.     ReplyMsg -- put a message to its reply port
  4047.  
  4048.    SYNOPSIS
  4049.     ReplyMsg(message)
  4050.          A1
  4051.  
  4052.     void ReplyMsg(struct Message *);
  4053.  
  4054.    FUNCTION
  4055.     This function sends a message to its reply port.  This is usually
  4056.     done when the receiver of a message has finished and wants to
  4057.     return it to the sender (so that it can be re-used or deallocated,
  4058.     whatever).
  4059.  
  4060.     This call may be made from interrupts.
  4061.  
  4062.    INPUT
  4063.     message - a pointer to the message
  4064.  
  4065.    IMPLEMENTATION
  4066.     1> Places "NT_REPLYMSG" into LN_TYPE.
  4067.     2> Puts the message to the port specified by MN_REPLYPORT
  4068.        If there is no replyport, sets LN_TYPE to "NT_FREEMSG" (use this
  4069.        feature only with extreme care).
  4070.  
  4071.    SEE ALSO
  4072.     GetMsg, PutMsg, exec/ports.h
  4073.  
  4074. exec.library/SendIO                                       exec.library/SendIO
  4075.  
  4076.    NAME
  4077.     SendIO -- initiate an I/O command
  4078.  
  4079.    SYNOPSIS
  4080.     SendIO(iORequest)
  4081.            A1
  4082.  
  4083.     void SendIO(struct IORequest *);
  4084.  
  4085.    FUNCTION
  4086.     This function requests the device driver start processing the given
  4087.     I/O request.  The device will return control without waiting for
  4088.     the I/O to complete.
  4089.  
  4090.     The io_Flags field of the IORequest will be set to zero before the
  4091.     request is sent.  See BeginIO() for more details.
  4092.  
  4093.    INPUTS
  4094.     iORequest - pointer to an I/O request, or a device specific
  4095.             extended IORequest.
  4096.  
  4097.    SEE ALSO
  4098.     DoIO, CheckIO, WaitIO, AbortIO
  4099.  
  4100. exec.library/SetExcept                                 exec.library/SetExcept
  4101.  
  4102.    NAME
  4103.     SetExcept -- define certain signals to cause exceptions
  4104.  
  4105.    SYNOPSIS
  4106.     oldSignals = SetExcept(newSignals, signalMask)
  4107.     D0               D0       D1
  4108.  
  4109.     ULONG SetExcept(ULONG,ULONG);
  4110.  
  4111.    FUNCTION
  4112.     This function defines which of the task's signals will cause a
  4113.     private task exception.  When any of the signals occurs the task's
  4114.     exception handler will be dispatched.  If the signal occurred prior
  4115.     to calling SetExcept, the exception will happen immediately.
  4116.  
  4117.     The user function pointed to by the task's tc_ExceptCode gets
  4118.     called as:
  4119.  
  4120.         newExcptSet = <exceptCode>(signals, exceptData),SysBase
  4121.         D0                   D0    A1        A6
  4122.  
  4123.         signals - The set of signals that caused this exception.  These
  4124.         Signals have been disabled from the current set of signals
  4125.         that can cause an exception.
  4126.  
  4127.         exceptData - A copy of the task structure tc_ExceptData field.
  4128.  
  4129.         newExcptSet - The set of signals in NewExceptSet will be re-
  4130.         enabled for exception generation.  Usually this will be the
  4131.         same as the Signals that caused the exception.
  4132.  
  4133.    INPUTS
  4134.     newSignals - the new values for the signals specified in
  4135.         signalMask.
  4136.     signalMask - the set of signals to be effected
  4137.  
  4138.    RESULTS
  4139.     oldSignals - the prior exception signals
  4140.  
  4141.    EXAMPLE
  4142.     Get the current state of all exception signals:
  4143.         SetExcept(0,0)
  4144.     Change a few exception signals:
  4145.         SetExcept($1374,$1074)
  4146.  
  4147.    SEE ALSO
  4148.     Signal, SetSignal
  4149.  
  4150. exec.library/SetFunction                             exec.library/SetFunction
  4151.  
  4152.    NAME
  4153.     SetFunction -- change a function vector in a library
  4154.  
  4155.    SYNOPSIS
  4156.     oldFunc = SetFunction(library, funcOffset, funcEntry)
  4157.     D0              A1       A0.W       D0
  4158.  
  4159.     APTR SetFunction(struct Library *,LONG,APTR);
  4160.  
  4161.    FUNCTION
  4162.     SetFunction is a functional way of changing where vectors in a
  4163.     library point.    They are changed in such a way that the
  4164.     checksumming process will never falsely declare a library to be
  4165.     invalid.
  4166.  
  4167.    WARNING
  4168.     If you use SetFunction on a function that can be called from
  4169.     interrupts, you are obligated to provide your own arbitration.
  4170.  
  4171.    NOTE
  4172.     SetFunction cannot be used on non-standard libraries like pre-V36
  4173.     dos.library.  Here you must manually Forbid(), preserve all 6
  4174.     original bytes, set the new vector, SumLibrary(), then Permit().
  4175.  
  4176.    INPUTS
  4177.     library    - a pointer to the library to be changed
  4178.     funcOffset - the offset of the function to be replaced
  4179.     funcEntry  - pointer to new function
  4180.  
  4181.    RESULTS
  4182.     oldFunc    - pointer to the old function that was just replaced
  4183.  
  4184. exec.library/SetIntVector                           exec.library/SetIntVector
  4185.  
  4186.    NAME
  4187.     SetIntVector -- set a new handler for a system interrupt vector
  4188.  
  4189.    SYNOPSIS
  4190.     oldInterrupt = SetIntVector(intNumber, interrupt)
  4191.     D0                D0         A1
  4192.  
  4193.     struct Interrupt *SetIntVector(ULONG, struct Interrupt *);
  4194.  
  4195.    FUNCTION
  4196.     This function provides a mechanism for setting the system interrupt
  4197.     vectors.  These are non-sharable; setting a new interrupt handler
  4198.     disconnects the old one.  Installed handlers are responsible for
  4199.     processing, enabling and clearing the interrupt.  Note that interrupts
  4200.     may have been left in any state by the previous code.
  4201.  
  4202.     The IS_CODE and IS_DATA pointers of the Interrupt structure will
  4203.     be copied into a private place by Exec.  A pointer to the previously
  4204.     installed Interrupt structure is returned.
  4205.  
  4206.     When the system calls the specified interrupt code, the registers are
  4207.     setup as follows:
  4208.  
  4209.         D0 - scratch
  4210.         D1 - scratch (on entry: active
  4211.               interrupts -> equals INTENA & INTREQ)
  4212.  
  4213.         A0 - scratch (on entry: pointer to base of custom chips
  4214.               for fast indexing)
  4215.         A1 - scratch (on entry: Interrupt's IS_DATA pointer)
  4216.  
  4217.         A5 - jump vector register (scratch on call)
  4218.         A6 - Exec library base pointer (scratch on call)
  4219.  
  4220.         all other registers must be preserved
  4221.  
  4222.    INPUTS
  4223.     intNum - the Paula interrupt bit number (0..14).  Only non-chained
  4224.          interrupts should be set.  Use AddIntServer() for server
  4225.          chains.
  4226.     interrupt - a pointer to an Interrupt structure containing the
  4227.          handler's entry point and data segment pointer.  A NULL
  4228.          interrupt pointer will remove the current interrupt and
  4229.          set illegal values for IS_CODE and IS_DATA.
  4230.  
  4231.          By convention, the LN_NAME of the interrupt structure must
  4232.          point a descriptive string so that other users may
  4233.          identify who currently has control of the interrupt.
  4234.  
  4235.    RESULT
  4236.     A pointer to the prior interrupt structure which had control
  4237.     of this interrupt.
  4238.  
  4239.    SEE ALSO
  4240.     AddIntServer(),exec/interrupts.i,hardware/intbits.i
  4241.  
  4242. exec.library/SetSignal                                 exec.library/SetSignal
  4243.  
  4244.    NAME
  4245.     SetSignal -- define the state of this task's signals
  4246.  
  4247.    SYNOPSIS
  4248.     oldSignals = SetSignal(newSignals, signalMask)
  4249.     D0               D0       D1
  4250.  
  4251.     ULONG SetSignal(ULONG,ULONG);
  4252.  
  4253.    FUNCTION
  4254.     This function can query or modify the state of the current task's
  4255.     received signal mask.  Setting the state of signals is considered
  4256.     dangerous.  Reading the state of signals is safe.
  4257.  
  4258.    INPUTS
  4259.     newSignals - the new values for the signals specified in
  4260.              signalSet.
  4261.     signalMask - the set of signals to be affected.
  4262.  
  4263.    RESULTS
  4264.     oldSignals - the prior values for all signals
  4265.  
  4266.    EXAMPLES
  4267.     Get the current state of all signals:
  4268.         SetSignal(0L,0L);
  4269.     Clear the CTRL-C signal:
  4270.         SetSignal(0L,SIGBREAKF_CTRL_C);
  4271.  
  4272.  
  4273.     Check if the CTRL-C signal was pressed:
  4274.  
  4275.         #include <libraries/dos.h>
  4276.  
  4277.         /* Check & clear CTRL_C signal */
  4278.         if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
  4279.         {
  4280.         printf("CTRL-C pressed!\n");
  4281.         }
  4282.  
  4283.    SEE ALSO
  4284.     Signal, Wait
  4285.  
  4286. exec.library/SetSR                                         exec.library/SetSR
  4287.  
  4288.    NAME
  4289.     SetSR -- get and/or set processor status register
  4290.  
  4291.    SYNOPSIS
  4292.     oldSR = SetSR(newSR, mask)
  4293.     D0          D0     D1
  4294.  
  4295.     ULONG SetSR(ULONG, ULONG);
  4296.  
  4297.    FUNCTION
  4298.     This function provides a means of modifying the CPU status register
  4299.     in a "safe" way (well, how safe can a function like this be
  4300.     anyway?).  This function will only affect the status register bits
  4301.     specified in the mask parameter.  The prior content of the entire
  4302.     status register is returned.
  4303.  
  4304.    INPUTS
  4305.     newSR - new values for bits specified in the mask.
  4306.         All other bits are not effected.
  4307.     mask - bits to be changed
  4308.  
  4309.    RESULTS
  4310.     oldSR - the entire status register before new bits
  4311.  
  4312.    EXAMPLES
  4313.     To get the current SR:
  4314.         currentSR = SetSR(0,0);
  4315.     To change the processor interrupt level to 3:
  4316.         oldSR = SetSR($0300,$0700);
  4317.     Set processor interrupts back to prior level:
  4318.         SetSR(oldSR,$0700);
  4319.  
  4320. exec.library/SetTaskPri                               exec.library/SetTaskPri
  4321.  
  4322.    NAME
  4323.     SetTaskPri -- get and set the priority of a task
  4324.  
  4325.    SYNOPSIS
  4326.     oldPriority = SetTaskPri(task, priority)
  4327.     D0-0:8             A1    D0-0:8
  4328.  
  4329.     BYTE SetTaskPri(struct Task *,LONG);
  4330.  
  4331.    FUNCTION
  4332.     This function changes the priority of a task regardless of its
  4333.     state.    The old priority of the task is returned.  A reschedule is
  4334.     performed, and a context switch may result.
  4335.  
  4336.     To change the priority of the currently running task, pass the
  4337.     result of FindTask(0); as the task pointer.
  4338.  
  4339.    INPUTS
  4340.     task - task to be affected
  4341.     priority - the new priority for the task
  4342.  
  4343.    RESULT
  4344.     oldPriority - the tasks previous priority
  4345.  
  4346. exec.library/Signal                                       exec.library/Signal
  4347.  
  4348.    NAME
  4349.     Signal -- signal a task
  4350.  
  4351.    SYNOPSIS
  4352.     Signal(task, signals)
  4353.            A1    D0
  4354.  
  4355.     void Signal(struct Task *,ULONG);
  4356.  
  4357.    FUNCTION
  4358.     This function signals a task with the given signals.  If the task
  4359.     is currently waiting for one or more of these signals, it will be
  4360.     made ready and a reschedule will occur. If the task is not waiting
  4361.     for any of these signals, the signals will be posted to the task
  4362.     for possible later use. A signal may be sent to a task regardless
  4363.     of whether it is running, ready, or waiting.
  4364.  
  4365.     This function is considered "low level".  Its main purpose is to
  4366.     support multiple higher level functions like PutMsg.
  4367.  
  4368.     This function is safe to call from interrupts.
  4369.  
  4370.    INPUT
  4371.     task - the task to be signalled
  4372.     signals - the signals to be sent
  4373.  
  4374.    SEE ALSO
  4375.     Wait, SetSignal
  4376.  
  4377. exec.library/StackSwap                                 exec.library/StackSwap
  4378.  
  4379.    NAME
  4380.     StackSwap - EXEC supported method of replacing task's stack      (V37)
  4381.  
  4382.    SYNOPSIS
  4383.     StackSwap(newStack)
  4384.               A0
  4385.  
  4386.     VOID StackSwap(struct StackSwapStruct *);
  4387.  
  4388.    FUNCTION
  4389.     This function will, in an EXEC supported manner, swap the
  4390.     stack of your task with the given values in StackSwap.
  4391.     The StackSwapStruct structure will then contain the values
  4392.     of the old stack such that the old stack can be restored.
  4393.     This function is new in V37.
  4394.  
  4395.    NOTE
  4396.     If you do a stack swap, only the new stack is set up.
  4397.     This function does not copy the stack or do anything else
  4398.     other than set up the new stack for the task.  It is
  4399.     generally required that you restore your stack before
  4400.     exiting.
  4401.  
  4402.    INPUTS
  4403.     newStack - A structure that contains the values for the
  4404.         new upper and lower stack bounds and the new stack
  4405.         pointer.  This structure will have its values
  4406.         replaced by those in you task such that you can
  4407.         restore the stack later.
  4408.  
  4409.    RESULTS
  4410.     newStack - The structure will now contain the old stack.
  4411.         This means that StackSwap(foo); StackSwap(foo);
  4412.         will effectively do nothing.
  4413.  
  4414.    SEE ALSO
  4415.     AddTask, RemTask, exec/tasks.h
  4416.  
  4417. exec.library/SumKickData                             exec.library/SumKickData
  4418.  
  4419.    NAME
  4420.     SumKickData -- compute the checksum for the Kickstart delta list
  4421.  
  4422.    SYNOPSIS
  4423.     checksum = SumKickData()
  4424.     D0
  4425.  
  4426.     ULONG SumKickData(void);
  4427.  
  4428.    FUNCTION
  4429.     The Amiga system has some ROM (or Kickstart) resident code that
  4430.     provides the basic functions for the machine.  This code is
  4431.     unchangeable by the system software.  This function is part of a
  4432.     support system to modify parts of the ROM.
  4433.  
  4434.     The ROM code is linked together at run time via ROMTags (also known
  4435.     as Resident structures, defined in exec/resident.h).  These tags tell
  4436.     Exec's low level boot code what subsystems exist in which regions of
  4437.     memory.  The current list of ROMTags is contained in the ResModules
  4438.     field of ExecBase.  By default this list contains any ROMTags found
  4439.     in the address ranges $F80000-$FFFFFF and $F00000-$F7FFFF.
  4440.  
  4441.     There is also a facility to selectively add or replace modules to the
  4442.     ROMTag list.  These modules can exist in RAM, and the memory they
  4443.     occupy will be deleted from the memory free list during the boot
  4444.     process.  SumKickData() plays an important role in this run-time
  4445.     modification of the ROMTag array.
  4446.  
  4447.     Three variables in ExecBase are used in changing the ROMTag array:
  4448.     KickMemPtr, KickTagPtr, and KickCheckSum. KickMemPtr points to a
  4449.     linked list of MemEntry structures. The memory that these MemEntry
  4450.     structures reference will be allocated (via AllocAbs) at boot time.
  4451.     The MemEntry structure itself must also be in the list.
  4452.  
  4453.     KickTagPtr points to a long-word array of the same format as the
  4454.     ResModules array.  The array has a series of pointers to ROMTag
  4455.     structures.  The array is either NULL terminated, or will have an
  4456.     entry with the most significant bit (bit 31) set.  The most
  4457.     significant bit being set says that this is a link to another
  4458.     long-word array of ROMTag entries.  This new array's address can be
  4459.     found by clearing bit 31.
  4460.  
  4461.     KickCheckSum has the result of SumKickData().  It is the checksum of
  4462.     both the KickMemPtr structure and the KickTagPtr arrays.  If the
  4463.     checksum does not compute correctly then both KickMemPtr and
  4464.     KickTagPtr will be ignored.
  4465.  
  4466.     If all the memory referenced by KickMemPtr can't be allocated then
  4467.     KickTagPtr will be ignored.
  4468.  
  4469.     There is one more important caveat about adding ROMTags. All this
  4470.     ROMTag magic is run very early on in the system -- before expansion
  4471.     memory is added to the system. Therefore any memory in this
  4472.     additional ROMTag area must be addressable at this time. This means
  4473.     that your ROMTag code, MemEntry structures, and resident arrays
  4474.     cannot be in expansion memory.  There are two regions of memory that
  4475.     are acceptable:  one is chip memory, and the other is "Ranger" memory
  4476.     (memory in the range between $C00000-$D80000).
  4477.  
  4478.     Remember that changing an existing ROMTag entry falls into the
  4479.     "heavy magic" category -- be very careful when doing it.  The odd are
  4480.     that you will blow yourself out of the water.
  4481.  
  4482.    NOTE
  4483.     SumKickData was introduced in the 1.2 release
  4484.  
  4485.    RESULT
  4486.     Value to be stuffed into ExecBase->KickCheckSum.
  4487.  
  4488.    WARNING
  4489.     After writing to KickCheckSum, you should push the data cache.
  4490.     This prevents potential problems with large copyback style caches.
  4491.     A call to CacheClearU will do fine.
  4492.  
  4493.    SEE ALSO
  4494.     InitResident, FindResident
  4495.  
  4496. exec.library/SumLibrary                               exec.library/SumLibrary
  4497.  
  4498.    NAME
  4499.     SumLibrary -- compute and check the checksum on a library
  4500.  
  4501.    SYNOPSIS
  4502.     SumLibrary(library)
  4503.            A1
  4504.  
  4505.     void SumLibrary(struct Library *);
  4506.  
  4507.    FUNCTION
  4508.     SumLibrary computes a new checksum on a library.  It can also be
  4509.     used to check an old checksum.    If an old checksum does not match,
  4510.     and the library has not been marked as changed, then the system
  4511.     will call Alert().
  4512.  
  4513.     This call could also be periodically made by some future
  4514.     system-checking task.
  4515.  
  4516.    INPUTS
  4517.     library - a pointer to the library to be changed
  4518.  
  4519.    NOTE
  4520.     An alert will occur if the checksum fails.
  4521.  
  4522.    SEE ALSO
  4523.     SetFunction
  4524.  
  4525. exec.library/SuperState                               exec.library/SuperState
  4526.  
  4527.    NAME
  4528.     SuperState -- enter supervisor state with user stack
  4529.  
  4530.    SYNOPSIS
  4531.     oldSysStack = SuperState()
  4532.     D0
  4533.  
  4534.     APTR SuperState(void);
  4535.  
  4536.    FUNCTION
  4537.     Enter supervisor mode while running on the user's stack. The user
  4538.     still has access to user stack variables.  Be careful though, the
  4539.     user stack must be large enough to accommodate space for all
  4540.     interrupt data -- this includes all possible nesting of interrupts.
  4541.     This function does nothing when called from supervisor state.
  4542.  
  4543.    RESULTS
  4544.     oldSysStack - system stack pointer; save this.    It will come in
  4545.               handy when you return to user state.  If the system
  4546.               is already in supervisor mode, oldSysStack is zero.
  4547.  
  4548.    SEE ALSO
  4549.     UserState/Supervisor
  4550.  
  4551.  
  4552. exec.library/Supervisor                               exec.library/Supervisor
  4553.  
  4554.    NAME
  4555.     Supervisor -- trap to a short supervisor mode function
  4556.  
  4557.    SYNOPSIS
  4558.     result = Supervisor(userFunc)
  4559.     Rx                   A5
  4560.  
  4561.     ULONG Supervisor(void *);
  4562.  
  4563.    FUNCTION
  4564.     Allow a normal user-mode program to execute a short assembly language
  4565.     function in the supervisor mode of the processor.  Supervisor() does
  4566.     not modify or save registers; the user function has full access to the
  4567.     register set.   All rules that apply to interrupt code must be
  4568.     followed.  In addition, no system calls are permitted.  The function
  4569.     must end with an RTE instruction.
  4570.  
  4571.    EXAMPLE
  4572.         ;Obtain the Exception Vector base.  68010 or greater only!
  4573.         MOVECtrap:    movec.l    VBR,d0    ;$4e7a,$0801
  4574.                 rte
  4575.  
  4576.    INPUTS
  4577.     userFunc - A pointer to a short assembly language function ending
  4578.            in RTE.  The function has full access to the register set.
  4579.  
  4580.    RESULTS
  4581.     result   - Whatever values the userFunc left in the registers.
  4582.  
  4583.    SEE ALSO
  4584.     SuperState,UserState
  4585.  
  4586. exec.library/TypeOfMem                                 exec.library/TypeOfMem
  4587.  
  4588.    NAME
  4589.     TypeOfMem -- determine attributes of a given memory address
  4590.  
  4591.    SYNOPSIS
  4592.     attributes = TypeOfMem(address)
  4593.     D0               A1
  4594.  
  4595.     ULONG TypeOfMem(void *);
  4596.  
  4597.    FUNCTION
  4598.     Given a RAM memory address, search the system memory lists and
  4599.     return its memory attributes.  The memory attributes are similar to
  4600.     those specified when the memory was first allocated: (eg. MEMF_CHIP
  4601.     and MEMF_FAST).
  4602.  
  4603.     This function is usually used to determine if a particular block of
  4604.     memory is within CHIP space.
  4605.  
  4606.     If the address is not in known-space, a zero will be returned.
  4607.     (Anything that is not RAM, like the ROM or expansion area, will
  4608.     return zero.  Also the first few bytes of a memory area are used up
  4609.     by the MemHeader.)
  4610.  
  4611.    INPUT
  4612.     address - a memory address
  4613.  
  4614.    RESULT
  4615.     attributes - a long word of memory attribute flags.
  4616.     If the address is not in known RAM, zero is returned.
  4617.  
  4618.    SEE ALSO
  4619.     AllocMem()
  4620.  
  4621. exec.library/UserState                                 exec.library/UserState
  4622.  
  4623.    NAME
  4624.     UserState -- return to user state with user stack
  4625.  
  4626.    SYNOPSIS
  4627.     UserState(sysStack)
  4628.           D0
  4629.  
  4630.     void UserState(APTR);
  4631.  
  4632.    FUNCTION
  4633.     Return to user state with user stack, from supervisor state with
  4634.     user stack.  This function is normally used in conjunction with the
  4635.     SuperState function above.
  4636.  
  4637.     This function must not be called from the user state.
  4638.  
  4639.    INPUT
  4640.     sysStack - supervisor stack pointer
  4641.  
  4642.    BUGS
  4643.     This function is broken in V33/34 Kickstart.  Fixed in V1.31 setpatch.
  4644.  
  4645.    SEE ALSO
  4646.     SuperState/Supervisor
  4647.  
  4648. exec.library/Vacate                                       exec.library/Vacate
  4649.  
  4650.    NAME
  4651.     Vacate -- release a bitMessage from Procure()                    (V39)
  4652.  
  4653.    SYNOPSIS
  4654.     Vacate(semaphore, bidMessage)
  4655.            A0         A1
  4656.  
  4657.     void Vacate(struct SignalSemaphore *,struct SemaphoreMessage *);
  4658.  
  4659.    FUNCTION
  4660.     This function can be used to release a semaphore obtained via
  4661.     Procure().  However, the main purpose for this call is to be
  4662.     able to remove a bid for a semaphore that has not yet responded.
  4663.     This is required when a Procure() was issued and the program
  4664.     no longer needs to get the semaphore and wishes to cancel the
  4665.     Procure() request.  The canceled request will be replied with
  4666.     the ssm_Semaphore field set to NULL.  If you own the semaphore,
  4667.     the message was already replied and only the ssm_Semaphore field
  4668.     will be cleared.
  4669.  
  4670.     NOTE:  Pre-V39, Procure() and Vacate() did not work correctly.
  4671.     They also did not operate on SignalSemaphore semaphores.
  4672.     Old (and broken) MessageSemaphore use as of V39 will no longer work.
  4673.  
  4674.    INPUT
  4675.     semaphore - The SignalSemaphore that you wish to Vacate()
  4676.     bidMessage- The SemaphoreMessage that you wish to abort.
  4677.         The message's ssm_Semaphore field will be cleared.
  4678.         The message will be replied if it is still on the waiting
  4679.         list.  If it is not on the waiting list, it is assumed
  4680.         that the semaphore is owned and it will be released.
  4681.  
  4682.    BUGS
  4683.     Before V39, Procure() and Vacate() used a different semaphore
  4684.     system that was very broken.  This new system is only available
  4685.     as of V39 even though the LVOs are the same.
  4686.  
  4687.    SEE ALSO
  4688.     ObtainSemaphoreShared(), InitSemaphore(), ReleaseSemaphore(),
  4689.     AttemptSemaphore(), ObtainSemaphoreList(), Procure(), ObtainSemaphore()
  4690.  
  4691. exec.library/Wait                                           exec.library/Wait
  4692.  
  4693.    NAME
  4694.     Wait -- wait for one or more signals
  4695.  
  4696.    SYNOPSIS
  4697.     signals = Wait(signalSet)
  4698.     D0           D0
  4699.  
  4700.     ULONG Wait(ULONG);
  4701.  
  4702.    FUNCTION
  4703.     This function will cause the current task to suspend waiting for
  4704.     one or more signals.  When one or more of the specified signals
  4705.     occurs, the task will return to the ready state, and those signals
  4706.     will be cleared.
  4707.  
  4708.     If a signal occurred prior to calling Wait(), the wait condition will
  4709.     be immediately satisfied, and the task will continue to run without
  4710.     delay.
  4711.  
  4712.    CAUTION
  4713.     This function cannot be called while in supervisor mode or
  4714.     interrupts!  This function will break the action of a Forbid() or
  4715.     Disable() call.
  4716.  
  4717.    INPUT
  4718.     signalSet - The set of signals for which to wait.
  4719.             Each bit represents a particular signal.
  4720.  
  4721.    RESULTS
  4722.     signals - the set of signals that were active
  4723.  
  4724. exec.library/WaitIO                                       exec.library/WaitIO
  4725.  
  4726.    NAME
  4727.     WaitIO -- wait for completion of an I/O request
  4728.  
  4729.    SYNOPSIS
  4730.     error = WaitIO(iORequest)
  4731.     D0           A1
  4732.  
  4733.     BYTE WaitIO(struct IORequest *);
  4734.  
  4735.    FUNCTION
  4736.     This function waits for the specified I/O request to complete, then
  4737.     removes it from the replyport.    If the I/O has already completed,
  4738.     this function will return immediately.
  4739.  
  4740.     This function should be used with care, as it does not return until
  4741.     the I/O request completes; if the I/O never completes, this
  4742.     function will never return, and your task will hang.  If this
  4743.     situation is a possibility, it is safer to use the Wait() function.
  4744.     Wait() will return return when any of a specified set of signal is
  4745.     received.  This is how I/O timeouts can be properly handled.
  4746.  
  4747.    WARNING
  4748.     If this IORequest was "Quick" or otherwise finished BEFORE this
  4749.     call, this function drops though immediately, with no call to
  4750.     Wait().  A side effect is that the signal bit related the port may
  4751.     remain set.  Expect this.
  4752.  
  4753.     When removing a known complete IORequest from a port, WaitIO() is the
  4754.     preferred method.  A simple Remove() would require a Disable/Enable
  4755.     pair!
  4756.  
  4757.    INPUTS
  4758.     iORequest - pointer to an I/O request block
  4759.  
  4760.    RESULTS
  4761.     error - zero if successful, else an error is returned
  4762.         (a sign extended copy of io_Error).
  4763.  
  4764.    SEE ALSO
  4765.     DoIO, SendIO, CheckIO, AbortIO
  4766.  
  4767. exec.library/WaitPort                                   exec.library/WaitPort
  4768.  
  4769.    NAME
  4770.     WaitPort -- wait for a given port to be non-empty
  4771.  
  4772.    SYNOPSIS
  4773.     message = WaitPort(port)
  4774.     D0           A0
  4775.  
  4776.     struct Message *WaitPort(struct MsgPort *);
  4777.  
  4778.    FUNCTION
  4779.     This function waits for the given port to become non-empty.  If
  4780.     necessary, the Wait() function will be called to wait for the port
  4781.     signal.  If a message is already present at the port, this function
  4782.     will return immediately.  The return value is always a pointer to
  4783.     the first message queued (but it is not removed from the queue).
  4784.  
  4785.    CAUTION
  4786.     More than one message may be at the port when this returns.  It is
  4787.     proper to call the GetMsg() function in a loop until all messages
  4788.     have been handled, then wait for more to arrive.
  4789.  
  4790.     To wait for more than one port, combine the signal bits from each
  4791.     port into one call to the Wait() function, then use a GetMsg() loop
  4792.     to collect any and all messages.  It is possible to get a signal
  4793.     for a port WITHOUT a message showing up.  Plan for this.
  4794.  
  4795.    INPUT
  4796.     port - a pointer to the message port
  4797.  
  4798.    RETURN
  4799.     message - a pointer to the first available message
  4800.  
  4801.    SEE ALSO
  4802.     GetMsg
  4803.  
  4804. SAD/--Overview--                                             SAD/--Overview--
  4805.  
  4806.     Simple Amiga Debugging Kernel, known as "SAD"
  4807.     It is in EXEC starting in V39
  4808.  
  4809.  
  4810.         -- General description --
  4811.  
  4812.  The Simple Amiga Debugging Kernel (SAD) is a set of very simple control
  4813.  routines stored in the Kickstart ROM that would let debuggers control the
  4814.  Amiga's development enviroment from the outside.  These tools would make
  4815.  it possible to do remote machine development/debugging via just the
  4816.  on-board serial port.
  4817.  
  4818.  This set of control routines is very simple and yet completely flexible,
  4819.  thus making it possible to control the whole machine.
  4820.  
  4821.  
  4822.         -- Technical Issues --
  4823.  
  4824.  SAD will make use of the motherboard serial port that exists in all
  4825.  Amiga systems.  The connection via the serial port lets the system be
  4826.  able to execute SAD without needing any of the system software up and
  4827.  running. (SAD will play with the serial port directly)
  4828.  
  4829.  With some minor changes to the Amiga hardware, an NMI-like line could
  4830.  be hooked up to a pin on the serial port.  This would let external
  4831.  control of the machine and would let the external controller stop the
  4832.  machine no matter what state it is in.  (NMI is that way)
  4833.  
  4834.  In order to function correctly, SAD requires the some of the EXEC
  4835.  CPU control functions work and that ExecBase be valid.  Beyond that,
  4836.  SAD does not require the OS to be running.
  4837.  
  4838.  
  4839.         -- Command Overview --
  4840.  
  4841.  The basic commands needed to operate SAD are as follows:
  4842.  
  4843.  Read and Write memory as byte, word, and longword.
  4844.  Get the register frame address (contains all registers)
  4845.  JSR to Address
  4846.  Return to system operation  (return from interrupt)
  4847.  
  4848.  These basic routines will let the system do whatever is needed.
  4849.  Since the JSR to address and memory read/write routines can be used
  4850.  to download small sections of code that could be used to do more
  4851.  complex things, this basic command set is thus flexible enough
  4852.  to even replace itself.
  4853.  
  4854.  Caches will automatically be flushed as needed after each write.
  4855.  (A call to CacheClearU() will be made after the write and before
  4856.  the command done sequence)
  4857.  
  4858.  
  4859.         -- Technical Command Descriptions --
  4860.  
  4861.  Since the communications with SAD is via a serial port, data formats
  4862.  have been defined for minimum overhead while still giving reasonable data
  4863.  reliability.  SAD will use the serial port at default 9600 baud but the
  4864.  external tools can change the serial port's data rate if it wishes.  It
  4865.  would need to make sure that it will be able to reconnect.  SAD sets
  4866.  the baud rate to 9600 each time it is entered.  However, while within
  4867.  SAD, a simple command to write a WORD to the SERPER register would
  4868.  change the baud rate.  This will remain in effect until you exit and
  4869.  re-enter SAD or until you change the register again.  (This can be usefull
  4870.  if you need to transfer a large amount of data)
  4871.  
  4872.  All commands have a basic format that they will follow.  All commands have
  4873.  both an ACK and a completion message.
  4874.  
  4875.  Basic command format is:
  4876.  
  4877.  SENDER:    $AF <command byte> [<data bytes as needed by command>]
  4878.  
  4879.  Receive:
  4880.  Command ACK:  $00 <command byte>
  4881.  
  4882.  Command Done: $1F <command byte> [<data if needed>]
  4883.  
  4884.  Waiting: $53 $41 $44 $BF
  4885.  
  4886.  Waiting when called from Debug():    $53 $41 $44 $3F
  4887.  
  4888.  Waiting when in dead-end crash:    $53 $41 $44 $21
  4889.  
  4890.  The data sequence will be that SAD will emit a $BF and then wait for a
  4891.  command. If no command is received within <2> seconds, it will emit $BF
  4892.  again and loop back.  (This is the "heart beat" of SAD)  When called from
  4893.  Debug() and not the NMI hook, SAD will use $3F as the "heart beat"
  4894.  
  4895.  If SAD does not get a responce after <10> heartbeats, it will return to
  4896.  the system.  (Execute an RTS or RTE as needed)  This is to prevent a full
  4897.  hang.  The debugger at the other end can keep SAD happy by sending a
  4898.  NO-OP command.
  4899.  
  4900.  All I/O in SAD times out.  During the transmition of a command, if
  4901.  more than 2 seconds pass between bytes of data SAD will time out
  4902.  and return to the prompt.  This is mainly to help make sure that
  4903.  SAD can never get into an i-loop situation.
  4904.  
  4905.  
  4906.         -- Data Structure Issues --
  4907.  
  4908.  While executing in SAD, you may have full access to machine from the CPU
  4909.  standpoint.  However, this could also be a problem.  It is important to
  4910.  understand that when entered via NMI that many system lists may be in
  4911.  unstable state.  (NMI can happen in the middle of the AllocMem routine
  4912.  or task switch, etc)
  4913.  
  4914.  Also, since you are doing debugging, it is up to you to determin what
  4915.  operations can be done and what can not be done.  A good example is
  4916.  that if you want to write a WORD or LONG that the address will need to
  4917.  be even on 68000 processors.  Also, if you read or write memory that does
  4918.  not exist, you may get a bus error.  Following system structures may
  4919.  require that you check the pointers at each step.
  4920.  
  4921.  When entered via Debug(), you are now running as a "task" so you will
  4922.  be able to assume some things about system structures.  This means that
  4923.  you are in supervisor state and that you can assume that the
  4924.  system is at least not between states.  However, remember that since
  4925.  you are debugging the system, some bad code could cause data structures
  4926.  to be invalid.  Again, standard debugging issues are in play.  SAD just
  4927.  gives you the hooks to do whatever you need.
  4928.  
  4929.  Note:  When SAD prompts with $BF you will be in full disable/forbid
  4930.  state.  When $3F prompting, SAD will only do a Forbid().  It is possible
  4931.  for you to then disable interrupts as needed.  This is done such that it
  4932.  is possible to "run" the system from SAD when called with Debug().
  4933.  
  4934.  
  4935.         -- Data Frames and the Registers --
  4936.  
  4937.  SAD generates a special data frame that can be used to read what
  4938.  registers contain and to change the contents of the registers.
  4939.  See the entry for GET_CONTEXT_FRAME for more details
  4940.  
  4941.  ----------------------------------------------------------------------------
  4942. -
  4943.  
  4944.  BUGS
  4945.     In V39 EXEC, the WRITE_BYTE command was not connected and this
  4946.     caused all of the command numbers to be off-by-one.  For example,
  4947.     the READ_WORD command is listed as command $05 but in V39 is $04.
  4948.     However, the ACK of the commands are still correct.
  4949.  
  4950.     Also, in V39 EXEC, the READ_WORD command would return the wrong
  4951.     data.
  4952.  
  4953.     To determin if you are in V39 or V40 SAD, you can issue a simple
  4954.     SAD command at the start of the session.  By sending a READ_WORD
  4955.     command, you may either get a READ_WORD (V40) or a READ_LONG (V39)
  4956.     ACK'ed back.  So the data stream for a safe test would be:
  4957.  
  4958.     Send: $AF $05 $00 $F8 $00 $00               ; Read start of ROM...
  4959.     Recv: $00 $05 ....   You have V40 SAD
  4960.     Recv: $00 $06 ....   You have V39 SAD
  4961.  
  4962.     Note that you should be ready to read either 2 or 4 bytes of
  4963.     result depending on the ACK sent by the system.
  4964.  
  4965. SAD/ALLOCATE_MEMORY                                       SAD/ALLOCATE_MEMORY
  4966.  
  4967.  ALLOCATE MEMORY
  4968.  
  4969.  Command:    $AF $0A
  4970.  Data:        $qq $rr $ss $tt $hh $ii $jj $kk
  4971.  
  4972.  Allocate a chunk of memory that is <$qqrrsstt> bytes in size.  Note
  4973.  that this call is only safe when SAD is in $3F prompting mode (called
  4974.  from Debug()) and even then may be unsafe if the system is in bad shape.
  4975.  (You are debugging after all)  The returned address will be available to
  4976.  you until you release it.  (It is obtained via a call to AllocVec())  The
  4977.  type of memory allocated is <$hhiijjkk>.  Note that the allocation may
  4978.  fail. In that case, the address returned will be $00000000.
  4979.  
  4980.  Command ACK:    $00 $0A
  4981.  Command DONE:    $1F $0A $ww $xx $yy $zz
  4982.  
  4983.  
  4984. SAD/CALL_ADDRESS                                             SAD/CALL_ADDRESS
  4985.  
  4986.  CALL ADDRESS - JSR to the given address.
  4987.  
  4988.  Command:    $AF $07
  4989.  Data:        $ww $xx $yy $zz
  4990.  
  4991.  Call the following address as a subroutine.  No registers will be
  4992.  set up but the context frame will exist.  Standard calling
  4993.  conventions apply (d0/d1/a0/a1 are available, rest must be saved)
  4994.  The command will be ACK'ed when received.
  4995.  Command ACK:    $00 $07
  4996.  Command DONE:    $1F $07
  4997.  
  4998.  
  4999. SAD/FREE_MEMORY                                               SAD/FREE_MEMORY
  5000.  
  5001.  FREE MEMORY
  5002.  
  5003.  Command:    $AF $0B
  5004.  Data:        $ww $xx $yy $zz
  5005.  
  5006.  Free the memory allocated with the ALLOCATE MEMORY command.  This command
  5007.  has the same restrictions as ALLOCATE MEMORY.  Memory is released by
  5008.  calling FreeVec() on the address <$wwxxyyzz>
  5009.  
  5010.  Command ACK:    $00 $0B
  5011.  Command DONE:    $1F $0B
  5012.  
  5013.  
  5014. SAD/GET_CONTEXT_FRAME                                   SAD/GET_CONTEXT_FRAME
  5015.  
  5016.  GET CONTEXT FRAME
  5017.  
  5018.  Command:    $AF $09
  5019.  Data:        <none>
  5020.  
  5021.  This command will return a pointer to the saved context.  This will be
  5022.  a pointer to all of the registers that were saved on the stack along
  5023.  with some other details.  Returns frame address <$wwxxyyzz>
  5024.  
  5025.  The pointer returned is to the following structure:
  5026.  
  5027.  STRUCTURE    SAD_FRAME,0
  5028.     ; The first three are READ-ONLY...  Mainly used to make it
  5029.     ; easier to understand what is going on in the system.
  5030.     ULONG    SAD_VBR        ; Current VBR (always 0 on 68000 CPUs)
  5031.     ULONG    SAD_AttnFlags    ; ULONG copy of the flags (UPPER WORD==0)
  5032.     ULONG    SAD_ExecBase    ; ExecBase
  5033.     ; These fields are the user registers...  The registers are
  5034.     ; restored from these fields on exit from SAD...
  5035.     ; Note that USP is only valid if SR was *NOT* supervisor...
  5036.     ULONG    SAD_USP        ; User stack pointer
  5037.     ULONG    SAD_D0        ; User register d0
  5038.     ULONG    SAD_D1        ; User register d1
  5039.     ULONG    SAD_D2        ; User register d2
  5040.     ULONG    SAD_D3        ; User register d3
  5041.     ULONG    SAD_D4        ; User register d4
  5042.     ULONG    SAD_D5        ; User register d5
  5043.     ULONG    SAD_D6        ; User register d6
  5044.     ULONG    SAD_D7        ; User register d7
  5045.     ULONG    SAD_A0        ; User register a0
  5046.     ULONG    SAD_A1        ; User register a1
  5047.     ULONG    SAD_A2        ; User register a2
  5048.     ULONG    SAD_A3        ; User register a3
  5049.     ULONG    SAD_A4        ; User register a4
  5050.     ULONG    SAD_A5        ; User register a5
  5051.     ULONG    SAD_A6        ; User register a6
  5052.     ; This is for SAD internal use...  It is the prompt that
  5053.     ; SAD is using...  Changing this will have no effect on SAD.
  5054.     ULONG    SAD_PROMPT    ; SAD Prompt Longword...  (internal use)
  5055.     ; From here on down is the standard exception frame
  5056.     ; The first two entries (SR and PC) are standard on all 680x0 CPUs
  5057.     UWORD    SAD_SR        ; Status register (part of exception frame)
  5058.     ULONG    SAD_PC        ; Return address (part of exception frame)
  5059.  
  5060.  
  5061.  Command ACK:    $00 $09
  5062.  Command DONE:    $1F $09 $ww $xx $yy $zz
  5063.  
  5064.  
  5065. SAD/NOP                                                               SAD/NOP
  5066.  
  5067.  NO-OP - Do nothing other than tell SAD you are still there...
  5068.  
  5069.  Command:    $AF $00
  5070.  Data:        <none>
  5071.  
  5072.  This just tells SAD you are still there.  Required so that timeouts do
  5073.  not exit SAD while you are not doing anything.
  5074.  
  5075.  This command will *NOT* be ACK'ed.  It will just cause the timeout to
  5076.  be restarted.
  5077.  
  5078.  
  5079. SAD/READ_ARRAY                                                 SAD/READ_ARRAY
  5080.  
  5081.  READ ARRAY - Read a range of bytes
  5082.  
  5083.  Command:    $AF $0F
  5084.  Data:        $ww $xx $yy $zz $qq $rr $ss $tt
  5085.  
  5086.  Read a range of bytes from address <$wwxxyyzz> for <$qqrrsstt> bytes
  5087.  Will return that number of bytes...
  5088.  
  5089.  Command will be ACK'ed when received.
  5090.  Command ACK:    $00 $0F
  5091.  Command DONE:    $1F $0F $uu [$uu ...]
  5092.  
  5093.  
  5094. SAD/READ_BYTE                                                   SAD/READ_BYTE
  5095.  
  5096.  READ BYTE - Read a byte from the given address
  5097.  
  5098.  Command:    $AF $04
  5099.  Data:        $ww $xx $yy $zz
  5100.  
  5101.  Read a byte from address <$wwxxyyzz>  Returns <$qq> as result
  5102.  
  5103.  Command will be ACK'ed when received.
  5104.  Command ACK:    $00 $04
  5105.  Command DONE:    $1F $04 $qq
  5106.  
  5107.  
  5108. SAD/READ_LONG                                                   SAD/READ_LONG
  5109.  
  5110.  READ LONG - Read a long from the given address
  5111.  
  5112.  Command:    $AF $06
  5113.  Data:        $ww $xx $yy $zz
  5114.  
  5115.  Read a long from address <$wwxxyyzz>  Returns <$qqrrsstt> as result
  5116.  
  5117.  Command will be ACK'ed when received.
  5118.  Command ACK:    $00 $06
  5119.  Command DONE:    $1F $06 $qq $rr $ss $tt
  5120.  
  5121.  
  5122. SAD/READ_WORD                                                   SAD/READ_WORD
  5123.  
  5124.  READ WORD - Read a word from the given address        (V40 SAD)
  5125.  
  5126.  Command:    $AF $05
  5127.  Data:        $ww $xx $yy $zz
  5128.  
  5129.  Read a word from address <$wwxxyyzz>  Returns <$qqrr> as result
  5130.  
  5131.  Command will be ACK'ed when received.
  5132.  Command ACK:    $00 $05
  5133.  Command DONE:    $1F $05 $qq $rr
  5134.  
  5135.  BUGS
  5136.     This command does not return correct values in pre-V40 EXEC.
  5137.  
  5138. SAD/RESET                                                           SAD/RESET
  5139.  
  5140.  RESET - Reset the computer...
  5141.  
  5142.  Command:    $AF $10
  5143.  Data:        $FF $FF $FF $FF
  5144.  
  5145.  This command will reset the computer.  the $FFFFFFFF value is there
  5146.  mainly to prevent false reset.  This command will only be ACK'ed as
  5147.  the computer will be reset afterwards...
  5148.  
  5149.  Command will be ACK'ed when received.
  5150.  Command ACK:    $00 $10
  5151.  
  5152.  
  5153. SAD/RETURN_TO_SYSTEM                                     SAD/RETURN_TO_SYSTEM
  5154.  
  5155.  RETURN TO SYSTEM
  5156.  
  5157.  Command:    $AF $08
  5158.  Data:        $00 $00 $00 $00
  5159.  
  5160.  This command will return <exit> from SAD back to whatever started it.
  5161.  The 4 $00 are required as a "safty" to this command.  The command
  5162.  will be ACK'ed only as it will have lost control of the system.
  5163.  
  5164.  Command ACK:    $00 $08
  5165.  
  5166.  
  5167. SAD/TURN_OFF_SINGLE                                       SAD/TURN_OFF_SINGLE
  5168.  
  5169.  TURN OFF SINGLE STEPPING
  5170.  
  5171.  Command:    $AF $0D
  5172.  Data:        $ww $xx $yy $zz
  5173.  
  5174.  This command will turn off SAD single stepping mode.  You need to pass
  5175.  to it the address returned from the call to turn on single stepping mode.
  5176.  
  5177.  Command ACK:    $00 $0D
  5178.  Command DONE:    $1F $0D
  5179.  
  5180.  
  5181. SAD/TURN_ON_SINGLE                                         SAD/TURN_ON_SINGLE
  5182.  
  5183.  TURN ON SINGLE STEPPING
  5184.  
  5185.  Command:    $AF $0C
  5186.  Data:        <none>
  5187.  
  5188.  This command will turn on SAD single stepping mode.  This means that SAD
  5189.  will single step (via 68000 trace mode) the system.  SAD will take over
  5190.  the TRACE exception vector during this time.  This command will return
  5191.  the contents of the vector such that you can return this value when
  5192.  you wish to turn off single stepping mode.  Note that turning on single
  5193.  stepping mode while in $BF prompting will cause the step to be taken
  5194.  and then SAD will execute in $3F mode (non-NMI)
  5195.  The command returns <$wwxxyyzz> which you must use when turning off
  5196.  the single-step mode.
  5197.  
  5198.  Command ACK:    $00 $0C
  5199.  Command DONE:    $1F $0C $ww $xx $yy $zz
  5200.  
  5201.  
  5202. SAD/WRITE_ARRAY                                               SAD/WRITE_ARRAY
  5203.  
  5204.  WRITE ARRAY - Write a range of bytes
  5205.  
  5206.  Command:    $AF $0E
  5207.  Data:        $ww $xx $yy $zz $qq $rr $ss $tt
  5208.  
  5209.  Write a range of bytes to address <$wwxxyyzz> for <$qqrrsstt> bytes
  5210.  After the computer sends the ACK, you must then send the byte stream...
  5211.  
  5212.  Command will be ACK'ed when received.
  5213.  Command ACK:    $00 $0E
  5214.  Command DONE:    $1F $0E
  5215.  
  5216.  
  5217. SAD/WRITE_BYTE                                                 SAD/WRITE_BYTE
  5218.  
  5219.  WRITE BYTE - Write the given data to the address given    (V40 SAD)
  5220.  
  5221.  Command:    $AF $01
  5222.  Data:        $ww $xx $yy $zz $qq
  5223.  
  5224.  Write the byte <$qq> to address <$wwxxyyzz>
  5225.  
  5226.  Command will be ACK'ed when received.
  5227.  Command ACK:    $00 $01
  5228.  Command DONE:    $1F $01
  5229.  
  5230.  BUGS
  5231.     This command does not exists in pre-V40 EXEC.
  5232.     This command can be emulated with the WRITE_ARRAY command with
  5233.     a length of 1.
  5234.  
  5235. SAD/WRITE_LONG                                                 SAD/WRITE_LONG
  5236.  
  5237.  WRITE LONG - Write the given data to the address given
  5238.  
  5239.  Command:    $AF $03
  5240.  Data:        $ww $xx $yy $zz $qq $rr $ss $tt
  5241.  
  5242.  Write the long <$qqrrsstt> to address <$wwxxyyzz>
  5243.  
  5244.  Command will be ACK'ed when received.
  5245.  Command ACK:    $00 $03
  5246.  Command DONE:    $1F $03
  5247.  
  5248.  
  5249. SAD/WRITE_WORD                                                 SAD/WRITE_WORD
  5250.  
  5251.  WRITE WORD - Write the given data to the address given
  5252.  
  5253.  Command:    $AF $02
  5254.  Data:        $ww $xx $yy $zz $qq $rr
  5255.  
  5256.  Write the word <$qqrr> to address <$wwxxyyzz>
  5257.  
  5258.  Command will be ACK'ed when received.
  5259.  Command ACK:    $00 $02
  5260.  Command DONE:    $1F $02
  5261.  
  5262.  
  5263.